CRM 2011 - getting formatted values ​​from a merged object

I used some CRM4.0 plugins to use CRM2011 SDK. I am just starting to work with LINQ for early objects and run into a problem.

I am trying to get the formatted OptionSetValue value in a merged entity. After looking at this example MSDN SDK request , I was able to get the formatted values ​​for the primary object, but it may not seem like it will translate to a merged object.

Below is an example of what I'm trying to achieve. I started by using the code from the SDK example.

var query_join8 = (from a in sContext.AccountSet
                    join c in sContext.ContactSet
                        on a.PrimaryContactId.Id equals c.ContactId
                        into gr
                    from c_joined in gr.DefaultIfEmpty()
                    select new
                                {
                                    contact_name = c_joined.FullName,
                                    account_name = a.Name,
                                    account_addresstypecode = a.Address1_AddressTypeCode,
                                    account_addresstypename = a.FormattedValues.ContainsKey("address1_addresstypecode") ? a.FormattedValues["address1_addresstypecode"] : null,
                                    account_formattedValues = a.FormattedValues,
                                    contact_addresstypecode = c_joined.Address1_AddressTypeCode,
                                    contact_addresstypename = c_joined.FormattedValues.ContainsKey("address1_addresstypecode") ? c_joined.FormattedValues["address1_addresstypecode"] : null,
                                    contact_formattedValues = c_joined.FormattedValues,
                                }).ToArray();

account_formattedValues ​​ account_addresstypename , , - contact_formattedValues ​​ , contact_addresstypename null.

, - ? - , ? .

+5
1

LINQ , , . , API QueryExpression ( LINQ) . / ( ). " " . FormattedValues.

var acs =
    from a in context.AccountSet
    join c in context.ContactSet on a.PrimaryContactId.Id equals c.ContactId
    into gr
    from c_joined in gr.DefaultIfEmpty()
    select new
    {
        account_addresstypecode = a.Address1_AddressTypeCode,
        account_addresstypename = a.FormattedValues["address1_addresstypecode"],
        contact_addresstypecode = c_joined.Address1_AddressTypeCode,
        contact_addresstypename = a.FormattedValues["c_0.address1_addresstypecode"],
        a.FormattedValues
    };

foreach (var ac in acs)
{
    foreach (var pair in ac.FormattedValues)
    {
        Console.WriteLine("{0} {1}", pair.Key, pair.Value);
    }
}

, "a". , / ( ), -set, "c" . , FormattedValues ​​ .

+8

All Articles