c# - Select from multiple list using LINQ -


i have multiple list of class.

public class mainclass {  public list<a> a{ get; set; }  public list<b> b{ get; set; }  public list<c> c{ get; set; } } 

and main class contains following property

 class     {       public string name{ get; set; }       public string mainaddress{get;set;}     }      class b     {       public int id {get;set;}       public string address{ get; set; }     }      class c     {      public int id {get;set;}       public string name{ get; set; }     } 

now how fetch data list b & c , pass a tried

  list<a> query = (from b in mainclass.b                join c in mainclass.c                 on b.id equals c.id                 select new {b.address, c.name}); 

how display name c mainaddress in a

heres complete snippet of demo code: http://share.linqpad.net/aq8f6c.linq

to address b displayed mainadress in following:

var result = in              join b in (from b in bs                         join c in cs                         on b.id equals c.id                         select new {b.address, c.name})              on a.name equals b.name              select new {                  name = a.name,                  mainaddress = b.address              }; 

result of type ienumerable<a>.

output:

enter image description here


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -