Linq - Left Outer Join RRS feed

  • Question

  • Getting object null reference 

    var searchedQueryDisposalList = (from callHistory in callHistoryResultSet.AsEnumerable()
                                                 join customer in tmCustomerResultSet.AsEnumerable() on callHistory.Customerid equals customer.CustomerId 
                                                 into a from lt in a.DefaultIfEmpty()
                                                 join queryReport in tmQueryResultSet.AsEnumerable() on callHistory.Id equals queryReport.CallId
                                                 into t from rt in t.DefaultIfEmpty()
                                                 orderby callHistory.Id 
                                                 select  new SearchedCallDisposal
                                                     Callid = callHistory.Id ,
                                                     CustomerName = lt.FullName ,
                                                     CallTerminationId = callHistory.DespositonCode,
                                                     AgentId = callHistory.AgentId,
                                                     //CenterId =     
                                                     CallStartTime = callHistory.CallStartTime ,
                                                     PhoneNumber = Convert.ToInt64(callHistory.CallerPhoneNumber),
                                                     What = (rt.What!=null)?rt.What:"",
                                                     Where = (rt.Where != null) ? rt.Where : "",
                                                     City = (rt.City != null) ? rt.City : ""
    What do I do wrong ?


    Friday, September 5, 2014 2:50 PM


  • Hello fak87,

    From your provide LION query, we cannot know which one causes this error, does it have a detail information which could show which part in the query is the caused reason? If it has, please share it with us.

    Since we cannot reproduce this issue, we can only provide some information and suggestions regarding this error:

    To make sure whether this is caused by the DefaultIfEmpty() method, you could remove properties based on t.DefaultIfEmpty()/a.DefaultIfEmpty() in the returned collection.

    Trying to check if the rt/lt is null as below rather than using its property:

    What = (rt!=null)?rt.What:"",

    If this does not work for you, please let me know.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, September 8, 2014 2:45 AM