// using System; using System.Collections.Generic; using System.Reflection; using DuSoft.PcmDb.Entities; using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal; using Microsoft.EntityFrameworkCore.Storage; #pragma warning disable 219, 612, 618 #nullable disable namespace DuSoft.PcmDb.CompiledEntities { internal partial class DostawcaEntityType { public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType baseEntityType = null) { var runtimeEntityType = model.AddEntityType( "DuSoft.PcmDb.Entities.Dostawca", typeof(Dostawca), baseEntityType); var kontrId = runtimeEntityType.AddProperty( "KontrId", typeof(decimal), propertyInfo: typeof(Dostawca).GetProperty("KontrId", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), fieldInfo: typeof(Dostawca).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly), afterSaveBehavior: PropertySaveBehavior.Throw, sentinel: 0m); kontrId.TypeMapping = SqlServerDecimalTypeMapping.Default.Clone( comparer: new ValueComparer( (decimal v1, decimal v2) => v1 == v2, (decimal v) => v.GetHashCode(), (decimal v) => v), keyComparer: new ValueComparer( (decimal v1, decimal v2) => v1 == v2, (decimal v) => v.GetHashCode(), (decimal v) => v), providerValueComparer: new ValueComparer( (decimal v1, decimal v2) => v1 == v2, (decimal v) => v.GetHashCode(), (decimal v) => v), mappingInfo: new RelationalTypeMappingInfo( storeTypeName: "numeric(9,0)", precision: 9, scale: 0)); kontrId.AddAnnotation("Relational:ColumnType", "numeric(9, 0)"); kontrId.AddAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.None); var towId = runtimeEntityType.AddProperty( "TowId", typeof(decimal), propertyInfo: typeof(Dostawca).GetProperty("TowId", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), fieldInfo: typeof(Dostawca).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly), afterSaveBehavior: PropertySaveBehavior.Throw, sentinel: 0m); towId.TypeMapping = SqlServerDecimalTypeMapping.Default.Clone( comparer: new ValueComparer( (decimal v1, decimal v2) => v1 == v2, (decimal v) => v.GetHashCode(), (decimal v) => v), keyComparer: new ValueComparer( (decimal v1, decimal v2) => v1 == v2, (decimal v) => v.GetHashCode(), (decimal v) => v), providerValueComparer: new ValueComparer( (decimal v1, decimal v2) => v1 == v2, (decimal v) => v.GetHashCode(), (decimal v) => v), mappingInfo: new RelationalTypeMappingInfo( storeTypeName: "numeric(9,0)", precision: 9, scale: 0)); towId.AddAnnotation("Relational:ColumnType", "numeric(9, 0)"); towId.AddAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.None); var cenaZak = runtimeEntityType.AddProperty( "CenaZak", typeof(decimal), propertyInfo: typeof(Dostawca).GetProperty("CenaZak", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), fieldInfo: typeof(Dostawca).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly), sentinel: 0m); cenaZak.TypeMapping = SqlServerDecimalTypeMapping.Default.Clone( comparer: new ValueComparer( (decimal v1, decimal v2) => v1 == v2, (decimal v) => v.GetHashCode(), (decimal v) => v), keyComparer: new ValueComparer( (decimal v1, decimal v2) => v1 == v2, (decimal v) => v.GetHashCode(), (decimal v) => v), providerValueComparer: new ValueComparer( (decimal v1, decimal v2) => v1 == v2, (decimal v) => v.GetHashCode(), (decimal v) => v), mappingInfo: new RelationalTypeMappingInfo( storeTypeName: "decimal(15,4)", precision: 15, scale: 4)); cenaZak.AddAnnotation("Relational:ColumnType", "decimal(15, 4)"); cenaZak.AddAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.None); var ileWZgrzewce = runtimeEntityType.AddProperty( "IleWZgrzewce", typeof(decimal?), propertyInfo: typeof(Dostawca).GetProperty("IleWZgrzewce", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), fieldInfo: typeof(Dostawca).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly), nullable: true); ileWZgrzewce.TypeMapping = SqlServerDecimalTypeMapping.Default.Clone( comparer: new ValueComparer( (Nullable v1, Nullable v2) => v1.HasValue && v2.HasValue && (decimal)v1 == (decimal)v2 || !v1.HasValue && !v2.HasValue, (Nullable v) => v.HasValue ? ((decimal)v).GetHashCode() : 0, (Nullable v) => v.HasValue ? (Nullable)(decimal)v : default(Nullable)), keyComparer: new ValueComparer( (Nullable v1, Nullable v2) => v1.HasValue && v2.HasValue && (decimal)v1 == (decimal)v2 || !v1.HasValue && !v2.HasValue, (Nullable v) => v.HasValue ? ((decimal)v).GetHashCode() : 0, (Nullable v) => v.HasValue ? (Nullable)(decimal)v : default(Nullable)), providerValueComparer: new ValueComparer( (Nullable v1, Nullable v2) => v1.HasValue && v2.HasValue && (decimal)v1 == (decimal)v2 || !v1.HasValue && !v2.HasValue, (Nullable v) => v.HasValue ? ((decimal)v).GetHashCode() : 0, (Nullable v) => v.HasValue ? (Nullable)(decimal)v : default(Nullable)), mappingInfo: new RelationalTypeMappingInfo( storeTypeName: "decimal(15,4)", precision: 15, scale: 4)); ileWZgrzewce.AddAnnotation("Relational:ColumnType", "decimal(15, 4)"); ileWZgrzewce.AddAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.None); var kod = runtimeEntityType.AddProperty( "Kod", typeof(string), propertyInfo: typeof(Dostawca).GetProperty("Kod", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), fieldInfo: typeof(Dostawca).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly), nullable: true, maxLength: 30, unicode: false); kod.TypeMapping = SqlServerStringTypeMapping.Default.Clone( comparer: new ValueComparer( (string v1, string v2) => v1 == v2, (string v) => v.GetHashCode(), (string v) => v), keyComparer: new ValueComparer( (string v1, string v2) => v1 == v2, (string v) => v.GetHashCode(), (string v) => v), providerValueComparer: new ValueComparer( (string v1, string v2) => v1 == v2, (string v) => v.GetHashCode(), (string v) => v), mappingInfo: new RelationalTypeMappingInfo( storeTypeName: "varchar(30)", size: 30)); kod.AddAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.None); var narzucany = runtimeEntityType.AddProperty( "Narzucany", typeof(short?), propertyInfo: typeof(Dostawca).GetProperty("Narzucany", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), fieldInfo: typeof(Dostawca).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly), nullable: true); narzucany.TypeMapping = SqlServerShortTypeMapping.Default.Clone( comparer: new ValueComparer( (Nullable v1, Nullable v2) => v1.HasValue && v2.HasValue && (short)v1 == (short)v2 || !v1.HasValue && !v2.HasValue, (Nullable v) => v.HasValue ? (int)(short)v : 0, (Nullable v) => v.HasValue ? (Nullable)(short)v : default(Nullable)), keyComparer: new ValueComparer( (Nullable v1, Nullable v2) => v1.HasValue && v2.HasValue && (short)v1 == (short)v2 || !v1.HasValue && !v2.HasValue, (Nullable v) => v.HasValue ? (int)(short)v : 0, (Nullable v) => v.HasValue ? (Nullable)(short)v : default(Nullable)), providerValueComparer: new ValueComparer( (Nullable v1, Nullable v2) => v1.HasValue && v2.HasValue && (short)v1 == (short)v2 || !v1.HasValue && !v2.HasValue, (Nullable v) => v.HasValue ? (int)(short)v : 0, (Nullable v) => v.HasValue ? (Nullable)(short)v : default(Nullable))); narzucany.AddAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.None); var rabatOdWart = runtimeEntityType.AddProperty( "RabatOdWart", typeof(decimal), propertyInfo: typeof(Dostawca).GetProperty("RabatOdWart", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), fieldInfo: typeof(Dostawca).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly), sentinel: 0m); rabatOdWart.TypeMapping = SqlServerDecimalTypeMapping.Default.Clone( comparer: new ValueComparer( (decimal v1, decimal v2) => v1 == v2, (decimal v) => v.GetHashCode(), (decimal v) => v), keyComparer: new ValueComparer( (decimal v1, decimal v2) => v1 == v2, (decimal v) => v.GetHashCode(), (decimal v) => v), providerValueComparer: new ValueComparer( (decimal v1, decimal v2) => v1 == v2, (decimal v) => v.GetHashCode(), (decimal v) => v), mappingInfo: new RelationalTypeMappingInfo( storeTypeName: "decimal(10,4)", precision: 10, scale: 4)); rabatOdWart.AddAnnotation("Relational:ColumnType", "decimal(10, 4)"); rabatOdWart.AddAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.None); var key = runtimeEntityType.AddKey( new[] { kontrId, towId }); runtimeEntityType.SetPrimaryKey(key); key.AddAnnotation("Relational:Name", "PK_DOSTAWCA"); var idx_DostTowId = runtimeEntityType.AddIndex( new[] { towId }, name: "idx_DostTowId"); return runtimeEntityType; } public static RuntimeForeignKey CreateForeignKey1(RuntimeEntityType declaringEntityType, RuntimeEntityType principalEntityType) { var runtimeForeignKey = declaringEntityType.AddForeignKey(new[] { declaringEntityType.FindProperty("KontrId") }, principalEntityType.FindKey(new[] { principalEntityType.FindProperty("KontrId") }), principalEntityType, required: true); var kontr = declaringEntityType.AddNavigation("Kontr", runtimeForeignKey, onDependent: true, typeof(Kontrahent), propertyInfo: typeof(Dostawca).GetProperty("Kontr", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), fieldInfo: typeof(Dostawca).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)); var dostawcaNavigation = principalEntityType.AddNavigation("DostawcaNavigation", runtimeForeignKey, onDependent: false, typeof(ICollection), propertyInfo: typeof(Kontrahent).GetProperty("DostawcaNavigation", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), fieldInfo: typeof(Kontrahent).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)); runtimeForeignKey.AddAnnotation("Relational:Name", "FK_DOSTAWCA_REF_KTHDO_KONTRAHE"); return runtimeForeignKey; } public static RuntimeForeignKey CreateForeignKey2(RuntimeEntityType declaringEntityType, RuntimeEntityType principalEntityType) { var runtimeForeignKey = declaringEntityType.AddForeignKey(new[] { declaringEntityType.FindProperty("TowId") }, principalEntityType.FindKey(new[] { principalEntityType.FindProperty("TowId") }), principalEntityType, required: true); var tow = declaringEntityType.AddNavigation("Tow", runtimeForeignKey, onDependent: true, typeof(Towar), propertyInfo: typeof(Dostawca).GetProperty("Tow", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), fieldInfo: typeof(Dostawca).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)); var dostawca = principalEntityType.AddNavigation("Dostawca", runtimeForeignKey, onDependent: false, typeof(ICollection), propertyInfo: typeof(Towar).GetProperty("Dostawca", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), fieldInfo: typeof(Towar).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)); runtimeForeignKey.AddAnnotation("Relational:Name", "FK_DOSTAWCA_REF_TOWDO_TOWAR"); return runtimeForeignKey; } public static void CreateAnnotations(RuntimeEntityType runtimeEntityType) { runtimeEntityType.AddAnnotation("Relational:FunctionName", null); runtimeEntityType.AddAnnotation("Relational:Schema", null); runtimeEntityType.AddAnnotation("Relational:SqlQuery", null); runtimeEntityType.AddAnnotation("Relational:TableName", "Dostawca"); runtimeEntityType.AddAnnotation("Relational:ViewName", null); runtimeEntityType.AddAnnotation("Relational:ViewSchema", null); Customize(runtimeEntityType); } static partial void Customize(RuntimeEntityType runtimeEntityType); } }