c# - Inner join in LINQ? -


this question has answer here:

how convert below inner join sql statement linq statement

 select ca.[cus_address_id]   ,ca.master_customer_id        ,ca.[address_1]         ,[city]   ,[state]   ,country_code   ,cad.address_type_code   ,cad.address_status_code      inner join [cus_address_detail] cad on ca.cus_address_id = cad.cus_address_id , cad.priority_seq = 0   ca.customer_id = '0000026' 

and assign

 public class location {            public string customernumber { get; set; }     public string city { get; set; }     public string state { get; set; }     public string country { get; set; }     public string addressloccode { get; set; }     public string addressstatus { get; set; } } 

the query wind looking (keep in mind, though, you'll have change field names match since little mangled):

var locations = c in customers                 join ca in customeraddresses                 on new { c.customeraddressid, 0 }                      equals new { ca.customeraddressid, ca.priorityseq }                 select new location                 {                     customernumber = c.mastercustomerid,                     city = ca.city,                     state = ca.state,                     country = ca.country,                     addressloccode = ca.addressloccode,                     addressstatus = ca.addressstatus                 }; 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -