假设我有一个包含 30 个属性的对象列表(例如Items
:)
如果我将 LINQ Query-Syntax 用于Join
另一个对象(例如Store
:),我似乎不可避免地必须从 重新分配每个属性Item
,对吧?
例如:
var temp = from a in items
join b in stores on a.storeKey = b.storeKey into b2
from c in b2.DefaultIfEmpty()
select new ItemViewModel()
{
p1 = a.p1,
p2 = a.p2,
....
p30 = a.p2, //re-assign 30 times (T.T)
storeInfo1 = c.storeInfo1 //all i want is 1 or 2 additional info from store
}