/// <summary> /// Set any values for the property configurations by conventions. This is called before the user-defined and after the default configuration is applied. /// </summary> protected virtual void SetConventionsForProperties() { var resourceIdName = typeof(TResource).Name.ToLowerInvariant() + "id"; var resourceIdPropertyConfig = PropertyConfigurations.FirstOrDefault(prop => prop.PropertyName.ToLower() == resourceIdName); var idPropertyConfig = PropertyConfigurations.FirstOrDefault(prop => prop.PropertyName.ToLower() == "id"); if (idPropertyConfig != null) { // Set column called Id to primary identifier CreatePropertyConfigurationBuilder <TResource>(idPropertyConfig).IsPrimaryIdentifier(); } else if (resourceIdPropertyConfig != null) { // Set column called [resource_type_name]Id to primary identifier (i.e. Person -> PersonId) CreatePropertyConfigurationBuilder <TResource>(resourceIdPropertyConfig).IsPrimaryIdentifier(); } }
protected override void SetConventionsForProperties() { base.SetConventionsForProperties(); var primaryKey = PropertyConfigurations.FirstOrDefault(x => x.IsPrimaryResourceIdentifier); if (primaryKey?.PropertyType == typeof(int)) { CreatePropertyConfigurationBuilder <int>(primaryKey).HasComputedValue(HttpVerbs.POST).AutoIncrementingInteger(); } else if (primaryKey?.PropertyType == typeof(Guid)) { CreatePropertyConfigurationBuilder <Guid>(primaryKey).HasComputedValue(HttpVerbs.POST).RandomlyGeneratedGuid(); } else if (primaryKey?.PropertyType == typeof(int?)) { CreatePropertyConfigurationBuilder <int?>(primaryKey).HasComputedValue(HttpVerbs.POST).AutoIncrementingInteger(); } else if (primaryKey?.PropertyType == typeof(Guid?)) { CreatePropertyConfigurationBuilder <Guid?>(primaryKey).HasComputedValue(HttpVerbs.POST).RandomlyGeneratedGuid(); } }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual PropertyConfiguration FindPropertyConfiguration([NotNull] IProperty property) { Check.NotNull(property, nameof(property)); return(PropertyConfigurations.FirstOrDefault(pc => pc.Property == property)); }
private Expression GetResultInitExpression(IDictionary <MemberInfo, Expression> memberInitis) { return(GetInitExpression(ResultType, memberInitis, p => PropertyConfigurations.FirstOrDefault(x => x.PropertyInfo == p)?.Property?.Default)); }