C# Linq - Join 2 Lists, add in extra properties to existing List -
suppose have following 2 classes set in c# program:
public class class1 { public string var1; public string var2; public string var3; public string var4; public string var5; } public class class2 { public string var1; public string var2; public string var3; public string var6; public string var7; }
and have following code in method:
public void mymethod() { list<class1> class1data = getclass1data(); list<class2> class2data = getclass2data(); var joineddata = (from c1 in class1data join c2 in class2data on new { c1.var1, c1.var2, c1.var3 } equals new { c2.var1, c2.var2, c2.var3 } select new { c1.var1, c1.var2, c1.var3, c1.var4, c1.var5, c2.var6, c2.var7 }).tolist(); }
now, i'd like, but, ideally, i'd extend class1
have 2 fields - var6
, var7
, have results class2
added onto class1data
list rather create new object joined data (trying conserve memory rather have 2 separate lists).
i'm sure has been asked , answered many times before, can't seem find best way this.
thanks!!
Comments
Post a Comment