When you create interactions its type is not an anonymous type of int and DateTime, it is of int and nullable DateTime. This is because in your inline if statement, you never call Value off of the nullable column. Your code should work if you create interactions like this: 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. Value : i. Create_Date_Time by pp.
Participation_Id into i1 select new {ParticipationId = i1. Key, CreateDateTime = i1.Max()} Simpler Example: var lst = new int? { 2,3,null,5,5 }; var lst2 = new int { 2,3,4,5,6 }; lst.
Select(x => x. HasValue?X. Value : 0).
Union(lst2); //works fine lst. Select(x => x. HasValue?
X : 0). Union(lst2); //throws error lst. Select(x => x?0).
Union(lst2); //also works Even though we can easily see that the inline if statement will never return a null value in either case, the compiler cannot make such guarantees and has to type the return value to that of a nullable int in the second case.
When you create interactions, its type is not an anonymous type of int and DateTime, it is of int and nullable DateTime. This is because in your inline if statement, you never call . Value off of the nullable column.
Your code should work if you create interactions like this: 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.
Value : i. Create_Date_Time by pp. Participation_Id into i1 select new {ParticipationId = i1.
Key, CreateDateTime = i1.Max()}; Simpler Example: var lst = new int? { 2,3,null,5,5 }; var lst2 = new int { 2,3,4,5,6 }; lst. Select(x => x.
HasValue? X. Value : 0).
Union(lst2); //works fine lst. Select(x => x. HasValue?
X : 0). Union(lst2); //throws error lst. Select(x => x?0).
Union(lst2); //also works Even though we can easily see that the inline if statement will never return a null value in either case, the compiler cannot make such guarantees and has to type the return value to that of a nullable int in the second case.
I am sorry I am not able to understand the . Value stuff. – Elan Feb 11 at 20:23 @Elan, The code in my answer is the corrected code.
Replace what you have with it. – diceguyd30 Feb 11 at 20:26 @diceguyd30, awesome, it worked fantastically. – Elan Feb 11 at 20:30 1 The grouping could be more easily expressed using null coalescing.
I. Last_Update_Date_Time?I. Create_Date_Time – Jeff Mercado Feb 11 at 20:37 @Jeff M Indeed, you are correct.
Edited to show that (if only in my simple example). – diceguyd30 Feb 11 at 20:43.
Most likely t1. Key and i1. Key are different types.
The anonymous types must have exactly the same property names and types, declared in the same order for you to be able to union them. As a side note, you probably also want to change this line of your code: transactions. Union(cases); to this: var unionedQuery = transactions.
Union(cases); otherwise it won't perform the union, because you've not stored the resulting query.
That is working for me, the problem istransactions. Union(interactions) Union of interactions is throwing an error – Elan Feb 11 at 19:19 Just because it didn't throw an error doesn't mean that it works, it can't be returning the unioned results if you haven't stored the resulting unioned IQueryable. – DoctaJonez Feb 11 at 19:21 I guess the ideal solution would be converting Linq.
ParallelQuery to Linq.IQueryable. However I do not know how to do this. – Elan Feb 11 at 19:23.
Error 1 Instance argument: cannot convert from 'System.Collections.Generic. List' to 'System.Linq. Error 2 'System.Collections.Generic.
List' does not contain a definition for 'Union' and the best extension method overload 'System.Linq.Queryable.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.