/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> public static bool ForAdd(this ValueGenerated valueGenerated) => (valueGenerated & ValueGenerated.OnAdd) != 0;
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> public static bool ForUpdate(this ValueGenerated valueGenerated) => (valueGenerated & ValueGenerated.OnUpdate) != 0;
private void SetValueGeneratorAndValueGenerated(IValueGenerator generator, ValueGenerated valueGenerated) { _valueGenerator = Check.NotNull(generator, nameof(generator)); _valueGenerated = valueGenerated; }
/// <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 void SetValueGenerated(ValueGenerated? valueGenerated, ConfigurationSource configurationSource) { _flags &= ~(int)PropertyFlags.ValueGenerated; if (valueGenerated == null) { _valueGeneratedConfigurationSource = null; } else { _flags |= ((int)valueGenerated + 1) << 8; UpdateValueGeneratedConfigurationSource(configurationSource); } }
private TableInfo GetFooTableInfo( bool withIdRow, ValueGenerated valueGenerated = ValueGenerated.OnUpdate) { var columns = new List <ColumnInfo>() { new ColumnInfo() { Name = "FirstName", PropertyInfo = GetPropertyInfo <Foo>("KrstneMeno") }, new ColumnInfo() { Name = "Salary", PropertyInfo = GetPropertyInfo <Foo>("Plat") }, new ColumnInfo() { Name = "Birthday", PropertyInfo = GetPropertyInfo <Foo>("DatumNarodena") }, new ColumnInfo() { Name = "Is", PropertyInfo = GetPropertyInfo <Foo>("Is") }, new ColumnInfo() { Name = "PropertyGuid", PropertyInfo = GetPropertyInfo <Foo>("PropertyGuid") }, new ColumnInfo() { Name = "PropertyStringGuid", PropertyInfo = GetPropertyInfo <Foo>("PropertyStringGuid") }, new ColumnInfo() { Name = "PropertyEnum", PropertyInfo = GetPropertyInfo <Foo>("PropertyEnum") }, new ColumnInfo() { Name = "PropertyDateTimeNullable", PropertyInfo = GetPropertyInfo <Foo>("PropertyDateTimeNullable") }, new ColumnInfo() { Name = "PropertyEnumConv", PropertyInfo = GetPropertyInfo <Foo>("PropertyEnumConv"), Converter = new TestEnumConverter() }, new ColumnInfo() { Name = "PropertyValueGenerator", PropertyInfo = GetPropertyInfo <Foo>("PropertyValueGenerator"), ValueGenerator = new AutoIncrementValueGenerator(), ValueGenerated = valueGenerated } }; if (withIdRow) { columns.Add(new ColumnInfo() { Name = "IdRow", PropertyInfo = GetPropertyInfo <Foo>("Id"), IsPrimaryKey = true }); } return(new TableInfo(columns, new List <PropertyInfo>(), null) { Name = "Foo" }); }
private TableInfo GetFooTableInfo( ValueGenerated valueGenerated = ValueGenerated.OnUpdate) => GetFooTableInfo(true, valueGenerated);
public RuntimeProperty( string name, Type clrType, PropertyInfo?propertyInfo, FieldInfo?fieldInfo, RuntimeEntityType declaringEntityType, PropertyAccessMode propertyAccessMode, bool nullable, bool concurrencyToken, ValueGenerated valueGenerated, PropertySaveBehavior beforeSaveBehavior, PropertySaveBehavior afterSaveBehavior, int?maxLength, bool?unicode, int?precision, int?scale, Type?providerClrType, Func <IProperty, IEntityType, ValueGenerator>?valueGeneratorFactory, ValueConverter?valueConverter, ValueComparer?valueComparer, ValueComparer?keyValueComparer, CoreTypeMapping?typeMapping) : base(name, propertyInfo, fieldInfo, propertyAccessMode) { DeclaringEntityType = declaringEntityType; ClrType = clrType; _isNullable = nullable; _isConcurrencyToken = concurrencyToken; _valueGenerated = valueGenerated; _beforeSaveBehavior = beforeSaveBehavior; _afterSaveBehavior = afterSaveBehavior; _valueGeneratorFactory = valueGeneratorFactory; _valueConverter = valueConverter; if (maxLength != null) { SetAnnotation(CoreAnnotationNames.MaxLength, maxLength); } if (unicode != null) { SetAnnotation(CoreAnnotationNames.Unicode, unicode); } if (precision != null) { SetAnnotation(CoreAnnotationNames.Precision, precision); } if (scale != null) { SetAnnotation(CoreAnnotationNames.Scale, scale); } if (providerClrType != null) { SetAnnotation(CoreAnnotationNames.ProviderClrType, providerClrType); } _typeMapping = typeMapping; _valueComparer = valueComparer; _keyValueComparer = keyValueComparer ?? valueComparer; }
protected virtual void OnValueGenerated(int value) { ValueGenerated?.Invoke(this, value); }
private static ValueDirection GetValudDirection(IProperty property, PropertySaveBehavior saveBehavior, ValueGenerated generatorFlag) { if (saveBehavior != PropertySaveBehavior.Save || (property.IsPrimaryKey() && property.ValueGenerated.HasFlag(generatorFlag))) { return(ValueDirection.Read); } else { var result = ValueDirection.Write; if (property.ValueGenerated.HasFlag(generatorFlag)) { result = result | ValueDirection.Read; } return(result); } }