1
0
mirror of https://git.teknik.io/Teknikode/Teknik.git synced 2023-08-02 14:16:22 +02:00

Added setting of case sensitive annotation for properties

This commit is contained in:
Uncled1023 2018-06-22 00:11:23 -07:00
parent b2902d7090
commit d401cd3f36

View File

@ -176,6 +176,9 @@ namespace Teknik.Data
modelBuilder.Entity<TransferType>().HasOne(t => t.User).WithMany(u => u.Transfers); modelBuilder.Entity<TransferType>().HasOne(t => t.User).WithMany(u => u.Transfers);
modelBuilder.Entity<TransferType>().HasOne(t => t.Paste).WithMany(p => p.Transfers); modelBuilder.Entity<TransferType>().HasOne(t => t.Paste).WithMany(p => p.Transfers);
// Transactions
modelBuilder.Entity<Transaction>().Property(t => t.Amount).HasColumnType("decimal(19, 5)");
// Users // Users
modelBuilder.Entity<User>().ToTable("Users"); modelBuilder.Entity<User>().ToTable("Users");
modelBuilder.Entity<UserRole>().ToTable("UserRoles"); modelBuilder.Entity<UserRole>().ToTable("UserRoles");
@ -218,20 +221,17 @@ namespace Teknik.Data
modelBuilder.Entity<TransferType>().ToTable("TransferTypes"); modelBuilder.Entity<TransferType>().ToTable("TransferTypes");
// Custom Attributes // Custom Attributes
//foreach (var entityType in modelBuilder.Model.GetEntityTypes()) foreach (var entityType in modelBuilder.Model.GetEntityTypes())
//{ {
// foreach (var property in entityType.GetProperties()) foreach (var property in entityType.GetProperties())
// { {
// var columnName = property.SqlServer().ColumnName; var attributes = property?.PropertyInfo?.GetCustomAttributes(typeof(CaseSensitiveAttribute), false);
// if (columnName.Length > 30) if (attributes != null && attributes.Any())
// { {
// throw new InvalidOperationException("Column name is greater than 30 characters - " + columnName); property.SetAnnotation("CaseSensitive", true);
// } }
// } }
//} }
//modelBuilder.Conventions.Add(new AttributeToColumnAnnotationConvention<CaseSensitiveAttribute, bool>(
// "CaseSensitive",
// (property, attributes) => attributes.Single().IsEnabled));
base.OnModelCreating(modelBuilder); base.OnModelCreating(modelBuilder);
} }