Пример #1
0
        private static EntityCollection GetUserProfiles(Guid ContactId, Guid?ProfileId)
        {
            if (ProfileId.HasValue)
            {
                OrganizationService srv = new OrganizationService(XrmConnection.Connection);
                using (CrmOrganizationServiceContext service = new CrmOrganizationServiceContext(srv))
                {
                    IQueryable <Entity> query = from entity in service.CreateQuery("appl_membershipprofile")
                                                where (Guid)entity["appl_contactid"] == ContactId && (Guid)entity["appl_profiledefinitionid"] == ProfileId.Value
                                                select entity;

                    EntityCollection col = new EntityCollection(query.ToList());
                    col.EntityName = "appl_membershipprofile";
                    return(col);
                }
            }
            else
            {
                return(XrmCore.GetRelated(new Entity("contact", ContactId), "appl_membershipprofile", "appl_contactid", CacheResults: false));
            }
        }