// 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 MagazynEntityType { public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType baseEntityType = null) { var runtimeEntityType = model.AddEntityType( "DuSoft.PcmDb.Entities.Magazyn", typeof(Magazyn), baseEntityType); var magId = runtimeEntityType.AddProperty( "MagId", typeof(decimal), propertyInfo: typeof(Magazyn).GetProperty("MagId", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), fieldInfo: typeof(Magazyn).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly), valueGenerated: ValueGenerated.OnAdd, afterSaveBehavior: PropertySaveBehavior.Throw, sentinel: 0m); magId.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)); magId.AddAnnotation("Relational:ColumnType", "numeric(9, 0)"); magId.AddAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); var nazwa = runtimeEntityType.AddProperty( "Nazwa", typeof(string), propertyInfo: typeof(Magazyn).GetProperty("Nazwa", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), fieldInfo: typeof(Magazyn).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly), maxLength: 40, unicode: false); nazwa.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(40)", size: 40)); nazwa.AddAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.None); var numer = runtimeEntityType.AddProperty( "Numer", typeof(short?), propertyInfo: typeof(Magazyn).GetProperty("Numer", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), fieldInfo: typeof(Magazyn).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly), nullable: true); numer.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))); numer.AddAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.None); var key = runtimeEntityType.AddKey( new[] { magId }); runtimeEntityType.SetPrimaryKey(key); key.AddAnnotation("Relational:Name", "PK_MAGAZYN"); return runtimeEntityType; } public static RuntimeSkipNavigation CreateSkipNavigation1(RuntimeEntityType declaringEntityType, RuntimeEntityType targetEntityType, RuntimeEntityType joinEntityType) { var skipNavigation = declaringEntityType.AddSkipNavigation( "Pol", targetEntityType, joinEntityType.FindForeignKey( new[] { joinEntityType.FindProperty("MagId") }, declaringEntityType.FindKey(new[] { declaringEntityType.FindProperty("MagId") }), declaringEntityType), true, false, typeof(ICollection), propertyInfo: typeof(Magazyn).GetProperty("Pol", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), fieldInfo: typeof(Magazyn).GetField("k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)); var inverse = targetEntityType.FindSkipNavigation("Mag"); if (inverse != null) { skipNavigation.Inverse = inverse; inverse.Inverse = skipNavigation; } return skipNavigation; } 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", "Magazyn"); runtimeEntityType.AddAnnotation("Relational:ViewName", null); runtimeEntityType.AddAnnotation("Relational:ViewSchema", null); Customize(runtimeEntityType); } static partial void Customize(RuntimeEntityType runtimeEntityType); } }