CRM: Values are not returned by Linq RRS feed

  • Question

  • Hi Friends,

    I'm facing the strange issue while querying the records in CRM using Linq. Fields are returned as null though those are having the value.


    When I queried business unit default team value using Linq it returned null but businessunitid was returned for the record. 

    Sample Query:

    var defaultteam= from bu in orgContext.CreateQuery("businessunit")
    where bu["businessunitid"]== new Guid("Guid")
    select bu["defaultteam"]
    And when I query the same using QueryByAttribute/FetchXML it returned the value.

    Have anyone faced this kind of issue?

    Saturday, November 1, 2014 6:40 AM

All replies

  • Hi,

    Please confirm you are getting ("Guid") value in your script- where bu["businessunitid"]== new Guid("Guid").
    first try by using hardcode value.
    Also check below link for help.


    Hope this help. Thanks

    Saturday, November 1, 2014 10:02 AM
  • Yes. Passing the Guid. Because if I get the businessunit object bu  instead of bu["defaultteam"]. it is returning the Business Unit id but defaultteam and all other fields value are null.
    Saturday, November 1, 2014 10:08 AM
  • Hi,

    try like this..

    var defaultteam = from bu in orgContext.CreateQuery("businessunit")
        where ((EntityReference)bu["businessunitid"]).Id.Equals(new Guid("fe28e0c6-7ad5-e211-9d01-00155d017a1e"))                    
        select new { abc = bu["name"] };
               foreach (var baccount in defaultteam)
                   string s = baccount.abc.ToString();

    • Edited by Suresh Sorde Saturday, November 1, 2014 11:12 AM
    Saturday, November 1, 2014 11:07 AM