Search Results

Search found 7676 results on 308 pages for 'linq extensions'.

Page 39/308 | < Previous Page | 35 36 37 38 39 40 41 42 43 44 45 46  | Next Page >

  • LINQ Nested Where

    - by griegs
    If I have the following model; public List<RecommendedProduct> recommendations Then public class RecommendedProduct public List<Product> Products Then the Product; public class Product public string Code The recommendations list has, as an example, 10 items in it. Each recommendations item has two Products in it. How, with LINQ, can I find the recommendations object that has products with both "A" and "B" product codes?

    Read the article

  • select multiple columns using linq and sum them up

    - by Yustme
    Hi, How can i select multiple columns and calculate the total amount. For example, in my database i got a few fields which are named: 5hunderedBills, 2hunderedBills, 1hunderedBills, etc. And the value of those fields are for example: 5, 2, 3 And the sum would be: 5hunderedBills * 5 + 2hunderedBills * 2 + 1hunderedBills * 3 How can i do that with LINQ in one select statement?

    Read the article

  • Getting A LINQ .InsertOnSubmit To Work

    - by Soo
    Hi SO, I'm trying to get an insert to work using LINQ and am having some difficulties. I am using this example to base my code: http://msdn.microsoft.com/en-us/library/bb763516.aspx I have my data object set up, but don't know what's going on when db.Orders.InsertOnSubmit is executed. How can I create this db object to insert a data object into my database using InsertOnSubmit?

    Read the article

  • sql and linq query

    - by ile
    Database has tables Photos and PhotoAlbums. I need query that will select all albums and only one photo from each album. I need SQL and LINQ version of this query. Thanks in advance.

    Read the article

  • Problem with LINQ Generated class and IEnumerable to Excel

    - by mehmet6parmak
    Hi all, I wrote a method which exports values to excel file from an IEnumerable parameter. Method worked fine for my little test class and i was happy till i test my method with a LINQ class. Method: public static void IEnumerableToExcel<T>(IEnumerable<T> data, HttpResponse Response) { Response.Clear(); Response.ContentEncoding = System.Text.Encoding.Default; Response.Charset = "windows-1254"; // set MIME type to be Excel file. Response.ContentType = "application/vnd.ms-excel;charset=windows-1254"; // add a header to response to force download (specifying filename) Response.AddHeader("Content-Disposition", "attachment;filename=\"ResultFile.xls\""); Type typeOfT = typeof(T); List<string> result = new List<string>(); FieldInfo[] fields = typeOfT.GetFields(); foreach (FieldInfo info in fields) { result.Add(info.Name); } Response.Write(String.Join("\t", result.ToArray()) + "\n"); foreach (T t in data) { result.Clear(); foreach (FieldInfo f in fields) result.Add((typeOfT).GetField(f.Name).GetValue(t).ToString()); Response.Write(String.Join("\t", result.ToArray()) + "\n"); } Response.End(); } My Little Test Class: public class Mehmet { public string FirstName; public string LastName; } Two Usage: Success: Mehmet newMehmet = new Mehmet(); newMehmet.FirstName = "Mehmet"; newMehmet.LastName = "Altiparmak"; List<Mehmet> list = new List<Mehmet>(); list.Add(newMehmet); DeveloperUtility.Export.IEnumerableToExcel<Mehmet>(list, Response); Fail: ExtranetDataContext db = new ExtranetDataContext(); DeveloperUtility.Export.IEnumerableToExcel<User>(db.Users, Response); Fail Reason: When the code reaches the code block used to get the fields of the template(T), it can not find any field for the LINQ Generated User class. For my weird class it works fine. Why? Thanks...

    Read the article

  • Linq-to-SQL question

    - by c11ada
    hey all, im really new to linq-to-SQL so this may sound like a really dumb question, i have the following code var query = from p in DC.General where p.GeneralID == Int32.Parse(row.Cells[1].Text) select new { p.Comment, }; how do i got about getting the result from this query to show in a text box ??

    Read the article

  • LINQ SELECT COUNT(*) AND EmployeeId

    - by Mahesh
    Hi, I have a table like below: EmployeeId EmployeeName RequestId RequestName EmployeeId RequestId I need to a to assign requests in a sequential fashion(those who has mininum number of requests). Can I know how to get employee who has minimum requests using linq??? Thanks, Mahesh

    Read the article

  • linq get sum of two columns in one query

    - by Axarydax
    Hi, let's say that I have a table called Items (ID int, Done int, Total int) I can do it by two queries: int total = m.Items.Sum(p=>p.Total) int done = m.Items.Sum(p=>p.Done) But I'd like to do it in one query, something like this: var x = from p in m.Items select new { Sum(p.Total), Sum(p.Done)}; Surely there is a way to call aggregate functions from LINQ syntax...?

    Read the article

  • Linq for java

    - by Milhous
    Would a LINQ for java be a useful tool? I have been working on a tool that will allow a java object to map to a row in a database. Would this be useful for java programmers? What features would be useful?

    Read the article

  • Need help for a complex linq query

    - by Jipy
    Ok so I've got a DataTable here's the schema DataTable dt = new DataTable(); dt.Columns.Add("word", typeof(string)); dt.Columns.Add("pronunciation", typeof(string)); The table is filled already and I'm trying to make a linq query so that i can output to the console or anywhere something like : Pronunciation : akses9~R => (list of words) I want to output the pronunciations the most common and all the words that use it.

    Read the article

  • Linq to object - Select Distinct

    - by Ben
    Hi, I can't quite figure out why this Linq Statement isn't working as i would expect: Dim distinctSurchargesList = (From thisparent As Parent In ThisParentCollection _ From thisChild As Child In thisparent.theseChildren _ Select New With {.childId = thischild.Id}).Distinct() I would assume that this would create a new collection of anonymous types, that would be distinct. Instead it creates a collection the size of the "ThisParentCollection" with duplicate "MyAnonymousType" in it (duplicate id's). Can anyone tell me where im going wrong? Thanks

    Read the article

  • Convert query from native SQL to LINQ request

    - by mike
    Please, help me. How i can translate this SQL query to LINQ request? SELECT TOP (1) PERCENT DATEDIFF(DAY, dbo.PO.ORDER_DATE, GETDATE()) AS Age FROM dbo.ITEMS INNER JOIN dbo.X_PO ON dbo.ITEMS.ITEMNO = dbo.X_PO.ITEM_CODE INNER JOIN dbo.PO ON dbo.X_PO.ORDER_NO = dbo.PO.DOC_NO AND dbo.X_PO.STATUS = dbo.PO.STATUS WHERE (dbo.ITEMS.ITEMNO = 'MBIN001') AND (dbo.X_PO.STATUS = 3) ORDER BY Age

    Read the article

  • linq where clause not in select statement

    - by Annie
    Can someone help me to convert from SQL Query to LINQ VB.NET: select rls.* from Roles rls(nolock) where rls.id not in ( select r.ID from usersRole ur (nolock) inner join Roles r(nolock) on ur.RoleID = r.ID where user_id = 'NY1772') Thanks

    Read the article

  • LINQ Equivalent for Standard Deviation

    - by Steven
    Does LINQ model the aggregate SQL function STDDEV() (standard deviation)? If not, what is the simplest / best-practices way to calculate it? Example: SELECT test_id, AVERAGE(result) avg, STDDEV(result) std FROM tests GROUP BY test_id

    Read the article

< Previous Page | 35 36 37 38 39 40 41 42 43 44 45 46  | Next Page >