Linq conversion instructions. Linq to ParallelQuery IQueryable

c# entity-framework linq linq-to-entities linq-to-objects


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
                               into i1
                               select new {ParticipationId = i1.Key, CreateDateTime = i1.Max()}).AsQueryable();

Given the code above, the following will function:


But the following won't work


Considering that both transactions and cases are returningLinq.IQueryable however the last one isLinq.ParallelQuery because it joins with a different table.

Basically, I need this feature to create Union.interactions.Union(transactions) or transactions.Union(interactions) with another.

2/11/2011 7:38:25 PM

Accepted Answer

Although my response to this query could be erroneous, I primarily raised it because of the following issue. Unable to unionize LINQ to Entities.

The excellent response I received from diceguyd30 resolved my issue. As a result, I am ending this inquiry in response to the resolution of my earlier inquiry.

5/23/2017 11:47:45 AM

Popular Answer

the unidentified kind oftransactions and cases is identical. the unidentified kind ofinteractions is 14-14-14!

The remedy is toselect in a manner that equalizes anonymous kinds. Therefore, either design your own type or typeify the features of the selected product.

The identical anonymous type should be generated by something similar for each select:

select new { ParticipationId = (int)c1.Key, CreateDateTime = (DateTime)c1.Max() }

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow