c# - LINQ union 2 tables -
i have table (t)
has references 2 additional tables (a
,b
) (both references null-able, there still 1 filled in per row). need union data 3. if row in (t)
references a
, need data a
, if b
, data b
. not problem, need project type, there collection of strings in table a
, table b
there no (assigning null
or enumerable.empty<string>()
or new list
... produces error). ideas?
illustration :
(from t in context.t join in context.a on t.refa_id equals a.id select new projectiontype { ... collectionproperty = a.collection }).union( t in context.t join b in context.b on t.refb_id equals b.id select new projectiontype { ... collectionproperty = what_should_i_put_there??? // needed because of union })
edit: maybe simple question be: how project empty collection in linq entities?
edit2: exception: a type implements ienumerable 'system.collections.generic.list...' cannot initialized in linq entities query.
it seems, defining dummy variable outside query works