I have managed to get the following working:
var transactions = from t in context.Transactions
group t.Create_Date_Time by t.Participation_Id
into t1
select new { ParticipationId = t1.Key, CreateDateTime = t1.Max() };
var cases = from c in context.Cases
group c.Create_Date_Time by c.Participation_Id
into c1
select new { ParticipationId = c1.Key, CreateDateTime = c1.Max() };
var interactions = from i in context.Interactions
join pp in context.Party_Participation on i.Party_Id equals pp.Party_Id
group i.Last_Update_Date_Time.HasValue ? i.Last_Update_Date_Time : i.Create_Date_Time
by pp.Participation_Id
into i1
select new { ParticipationId = i1.Key, CreateDateTime = i1.Max() };
transactions.Union(cases);
However at last when I was trying to add third output,
transactions.Union(interactions);
// or
interactions.Union(transactions);
I got the following error
either way it is throwing following error
Error 1 Instance argument: cannot convert from 'System.Collections.Generic.List<AnonymousType#1>' to 'System.Linq.IQueryable<AnonymousType#2>'
Error 2 'System.Collections.Generic.List<AnonymousType#1>' does not contain a definition for 'Union' and the best extension method overload 'System.Linq.Queryable.Union<TSource>(System.Linq.IQueryable<TSource>, System.Collections.Generic.IEnumerable<TSource>)' has some invalid arguments
The only difference in third sequence is, I am using join with another table. I have tried .AsEnumerable()
, .ToList()
and .ToArray()
, none of them helped.