i have 2 different classes below:
public class productdto : idto { public int parentproductid { get; set; } public string parentproductnumber { get; set; } public int supplierid { get; set; } //more properties } public class orderitemsdto : idto { public int poid { get; set; } public system.datetime createddate { get; set; } public int parentproductid { get; set; } public int variationid { get; set; } public system.datetime deliverydate { get; set; } //more properties } what need join list<orderitemsdto> , list<productdto> on parentproductid (like if database tables) , produce list.
i have tried using union below:
list<productdto> productparents = productmanager.getlist(); list<orderitemsdto> orderitemslist = ordermanager.getlist(); gvpurchaseorderitems.datasource = orderitemslist.select(o => o.parentproductid).union(productparents.select(pp => pp.parentproductid)); but gives me result of list<int> parentproductids found in both of lists need has properties ( columns in above case ) both classes. , couldn't find how select multiple properties select extension method ( kind of beginner )
i know can create new class , map properties manually, curious how lambda expressions or linq. possible, appreciate if point me direction. thanks.
you can use select create anonymous type query:
orderitemslist.select(o => new { o.parentproductid, o.variationid, /* etc */ }) so, in case:
gvpurchaseorderitems.datasource = orderitemslist .select(o => new { o.parentproductid, o.variationid, /* etc */ }) .union(productparents .select(pp => new { pp.parentproductid, pp.variationid, /* etc */ }));
Comments
Post a Comment