protected virtual bool SetValueGenerationStrategy(AS400ValueGenerationStrategy?value) { if (value != null) { var propertyType = Property.ClrType; if (value == AS400ValueGenerationStrategy.IdentityColumn && !IsCompatibleIdentityColumn(propertyType)) { if (ShouldThrowOnInvalidConfiguration) { throw new ArgumentException(EFCoreStrings.IdentityBadType( Property.Name, Property.DeclaringEntityType.DisplayName(), propertyType.ShortDisplayName())); } return(false); } if (value == AS400ValueGenerationStrategy.SequenceHiLo && !IsCompatibleSequenceHiLo(propertyType)) { if (ShouldThrowOnInvalidConfiguration) { throw new ArgumentException(EFCoreStrings.SequenceBadType( Property.Name, Property.DeclaringEntityType.DisplayName(), propertyType.ShortDisplayName())); } return(false); } } if (!CanSetValueGenerationStrategy(value)) { return(false); } if (!ShouldThrowOnConflict && ValueGenerationStrategy != value && value != null) { ClearAllServerGeneratedValues(); } return(Annotations.SetAnnotation(AS400AnnotationNames.ValueGenerationStrategy, value)); }
public override void ValidateTypeName(string storeType) { var _disallowedMappings = new DisallowedMappings_AS400(); if (_disallowedMappings.Contains(storeType)) { throw new ArgumentException(EFCoreStrings.UnqualifiedDataType(storeType)); } }
protected virtual void ValidateNonKeyValueGeneration([NotNull] IModel model) { var properties = from p in model.GetRootEntityTypesDeclaredProperties() where ((AS400PropertyAnnotations)p.AS400()).GetAS400ValueGenerationStrategy(false) == AS400ValueGenerationStrategy.SequenceHiLo && !p.IsKey() select p; foreach (var property in properties) { throw new InvalidOperationException(EFCoreStrings.NonKeyValueGeneration(property.Name, property.DeclaringEntityType.DisplayName())); } }
//protected override void ValidateSharedTableCompatibility( // IReadOnlyList<IEntityType> mappedTypes, string tableName) { // var firstMappedType = mappedTypes[0]; // var isMemoryOptimized = firstMappedType.AS400().IsMemoryOptimized; // foreach (var otherMappedType in mappedTypes.Skip(1)) { // if (isMemoryOptimized != otherMappedType.AS400().IsMemoryOptimized) { // throw new InvalidOperationException( // EFCoreStrings.IncompatibleTableMemoryOptimizedMismatch( // tableName, firstMappedType.DisplayName(), otherMappedType.DisplayName(), // isMemoryOptimized ? firstMappedType.DisplayName() : otherMappedType.DisplayName(), // !isMemoryOptimized ? firstMappedType.DisplayName() : otherMappedType.DisplayName())); // } // } // base.ValidateSharedTableCompatibility(mappedTypes, tableName); //} protected override void ValidateSharedColumnsCompatibility(IReadOnlyList <IEntityType> mappedTypes, string tableName) { base.ValidateSharedColumnsCompatibility(mappedTypes, tableName); var identityColumns = mappedTypes.SelectMany(et => et.GetDeclaredProperties()) .Where(p => p.AS400().ValueGenerationStrategy == AS400ValueGenerationStrategy.IdentityColumn) .Distinct((p1, p2) => p1.Name == p2.Name) .ToList(); if (identityColumns.Count > 1) { var sb = new StringBuilder() .AppendJoin(identityColumns.Select(p => "'" + p.DeclaringEntityType.DisplayName() + "." + p.Name + "'")); throw new InvalidOperationException(EFCoreStrings.MultipleIdentityColumns(sb, tableName)); } }