/// <summary>
        /// Gets the actual type of the entity as defined by the entity LogicalName, even if it is just an entity.
        /// ie: (new Entity(Contact.EntityLogicalName)).GetEntityType() == (new Contact()).GetType()
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        public static Type GetEntityType(this Entity entity)
        {
            var assembly = CrmServiceUtility.GetEarlyBoundProxyAssembly();

            foreach (var t in assembly.GetTypes())
            {
                var attribute =
                    (EntityLogicalNameAttribute)
                    t.GetCustomAttributes(typeof(EntityLogicalNameAttribute), false).FirstOrDefault();
                if (attribute != null && attribute.LogicalName == entity.LogicalName)
                {
                    return(t);
                }
            }
            throw new Exception("Type " + entity.LogicalName + " Not found!");
        }
 public ClientSideOrganizationService(string crmOrganizationUrl, string crmDiscoveryUrl, string crmOrganization,
                                      string domain, string userName, string password, bool enableProxyTypes = true) :
     this(CrmServiceUtility.GetOrganizationService(crmOrganizationUrl, crmDiscoveryUrl, crmOrganization,
                                                   domain, userName, password, enableProxyTypes))
 {
 }
 public ClientSideOrganizationService(string crmOrganizationUrl, string crmDiscoveryUrl, string crmOrganization,
                                      Guid impersonationUserId = new Guid(), bool enableProxyTypes = true) :
     this(CrmServiceUtility.GetOrganizationService(crmOrganizationUrl, crmDiscoveryUrl, crmOrganization,
                                                   impersonationUserId, enableProxyTypes))
 {
 }
 public ClientSideOrganizationService(string crmOrganization, Guid impersonationUserId = new Guid()) :
     this(CrmServiceUtility.GetOrganizationService(crmOrganization, impersonationUserId))
 {
 }
 public ClientSideOrganizationService(CrmServiceInfo info) :
     this(CrmServiceUtility.GetOrganizationService(info))
 {
 }
Exemple #6
0
 public ClientSideOrganizationService(string connectionString) :
     this(CrmServiceUtility.GetOrganizationService(connectionString))
 {
 }
Exemple #7
0
 public ClientSideOrganizationService() :
     this(CrmServiceUtility.GetOrganizationService())
 {
 }