none
Using Linq Query in our program error is thrown :Exception has been thrown by the target of an invocation. RRS feed

  • Question

  • Hi All,

      I am writing the below linq query to fetch the record from the database ,

    var individualres = (from c in orgContext.CreateQuery("contact")
                                                 join a in orgContext.CreateQuery("annotation")
                                                      on c["contactid"] equals a["objectid"]
                                                 where (bool)a["isdocument"] == true && a["objectid"] == r.GUID && a["filename"] != null
                                                 select new
                                                 {
                                                     FirstName = c["firstname"],
                                                     LastName = c["lastname"],                                                 
                                                     CreatedDate=a["createdon"],
                                                     DocumentBody = (a["documentbody"] == null) ? "" : a["documentbody"],
                                                     GUID = c["contactid"],
                                                     FileName = a["filename"],
                                                     WorkStatus = (c["new_workstatus"] == null) ? "" : c["new_workstatus"],
                                                     Rank = (c["new_rank"] == null) ? "" : c["new_rank"],
                                                     State = (c["address1_stateorprovince"] == null) ? "" : c["address1_stateorprovince"],
                                                     City = (c["address1_city"] == null) ? "" : c["address1_city"]

                                                 });

    But it is throwing the error   Exception has been thrown by the target of an invocation.

    if this error is related to null values into the columns , then i am handling those by using the 

    ternary operator.

    Can anybody help me out for this issue.

    thanks in advance.

    • Moved by Charles-Li Thursday, April 23, 2015 5:28 AM
    Wednesday, April 22, 2015 10:48 AM

All replies