I think the post you took the code from answers your question as well (bold is mine) This works as written since it is in LINQ to Objects If LINQ to SQL or other, the overload of DefaultIfEmpty() that takes in a default may not work. Then you'd have to use the conditional operator to conditionally get the values i. E var leftOuterJoin = from first in firstNames join last in lastNames on first.ID equals last.
ID into temp from last in temp.DefaultIfEmpty() select new { first. ID, FirstName = first.Name, LastName = last! = null?
Last.Name : default(string), } Update from Robb This is the answer, and I was able to get my code working by converting the IQueryable to a List using ToList() My comment on update Definitely this is another option if you don't want you join s to run on the database and you're comfortable with doing them on objects. However this may affect performance if there are really many objects (how many—it depends). Follow the usual optimization mantra: measure, measure and measure If this is of no concern ToList will work fine.
I think the post you took the code from answers your question as well (bold is mine). This works as written since it is in LINQ to Objects. If LINQ to SQL or other, the overload of DefaultIfEmpty() that takes in a default may not work.
Then you'd have to use the conditional operator to conditionally get the values. I.e. , var leftOuterJoin = from first in firstNames join last in lastNames on first.ID equals last.
ID into temp from last in temp.DefaultIfEmpty() select new { first. ID, FirstName = first.Name, LastName = last! = null?
Last.Name : default(string), }; Update from Robb This is the answer, and I was able to get my code working by converting the IQueryable to a List using ToList(). My comment on update Definitely this is another option if you don't want you joins to run on the database and you're comfortable with doing them on objects. However this may affect performance if there are really many objects (how many—it depends).
Follow the usual optimization mantra: measure, measure and measure. If this is of no concern, ToList will work fine.
Thanks for that - I totally missed that statement - I was so jazzed to find a solution. I am going to give it some effort and will get back to this question. Thanks again!
– Robb Sadler Jul 29 at 14:19 @Robb: I removed the code sample because it is easy to deduce from what you're saying and takes a very large part of answer itself. However I did some elaboration on your solution. – Dan Abramov Jul 29 at 15:06 That's cool - appreciate the additional input.
Linq is very exciting and giving me a headache at the same time! Hopefully a couple more months and I'll have my brain wrapped around it. – Robb Sadler Jul 29 at 18:23 Unfortunately after changing to the conditional the compiler told me I was out of scope on the (equivalent of last above).
I have no time left so have to run with what I have and I will keep an eye on the performance. – Robb Sadler Jul 29 at 18:49.
JoinLeft.Dump(); // raises: NotSupportedException: Unsupported overload used for query operator 'DefaultIfEmpty'. New { JoinId = "12345", ActivityDate = DateTime. New { JoinId = "23456", ActivityDate = DateTime.
New { JoinId = "34567", ActivityDate = DateTime. New { JoinId = "12345", CompletedDate = DateTime. New { JoinId = "23456", CompletedDate = DateTime.
New { JoinId = "45678", CompletedDate = DateTime. JoinId equals act. From act in temp.
JoinId = (string)ph. ActivityDate = (DateTime)ph. UserName = (string)ph.
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.