private EntityMetadata(Type type) { BindingType = type; EntityDefinition = DefinitionCache.GetEntityDefinitionFromModelType(type); TypeFullName = type.FullName; IsValidForCreate = type.GetCustomAttribute <CrmEntityAttribute>().ValidForCreate; AllowDeactivation = type.GetCustomAttribute <CrmEntityAttribute>().AllowDeactivation; IdProperty = type.GetProperty("Id"); var attributes = new List <AttributeMetadata>(); var extendBindingProperties = new List <PropertyInfo>(); var crmRelationshipProperties = new List <PropertyInfo>(); var allProperties = new List <PropertyInfo>(); foreach (var property in type.GetProperties()) { if (property.GetCustomAttribute <CrmMappingAttribute>() != null) { attributes.Add(new AttributeMetadata(EntityDefinition, property)); } else if (property.GetCustomAttributes <ExtendBindingModelAttribute>().Any()) { extendBindingProperties.Add(property); } else if (property.GetCustomAttributes <CrmRelationshipAttribute>().Any()) { crmRelationshipProperties.Add(property); } allProperties.Add(property); } CrmAttributes = attributes; ExtendBindingProperties = extendBindingProperties; CrmRelationshipProperties = crmRelationshipProperties; AllProperties = allProperties; IsBindingModelBase = typeof(BindingModelBase).IsAssignableFrom(type); }