// using System; using System.Collections.Generic; using System.Reflection; 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 Blink.Backoffice.Services.PcmDb.CompiledEntities { internal partial class PrzydzialEntityType { public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType baseEntityType = null) { var runtimeEntityType = model.AddEntityType( "Przydzial", typeof(Dictionary), baseEntityType, sharedClrType: true, indexerPropertyInfo: RuntimeEntityType.FindIndexerProperty(typeof(Dictionary)), propertyBag: true); var kasaId = runtimeEntityType.AddProperty( "KasaId", typeof(decimal), propertyInfo: runtimeEntityType.FindIndexerPropertyInfo(), afterSaveBehavior: PropertySaveBehavior.Throw); kasaId.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)); kasaId.AddAnnotation("Relational:ColumnType", "numeric(9, 0)"); kasaId.AddAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.None); var asId = runtimeEntityType.AddProperty( "AsId", typeof(decimal), propertyInfo: runtimeEntityType.FindIndexerPropertyInfo(), afterSaveBehavior: PropertySaveBehavior.Throw); asId.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)); asId.AddAnnotation("Relational:ColumnType", "numeric(9, 0)"); asId.AddAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.None); var key = runtimeEntityType.AddKey( new[] { kasaId, asId }); runtimeEntityType.SetPrimaryKey(key); key.AddAnnotation("Relational:Name", "PK_PRZYDZIAL"); var index = runtimeEntityType.AddIndex( new[] { asId }); return runtimeEntityType; } public static RuntimeForeignKey CreateForeignKey1(RuntimeEntityType declaringEntityType, RuntimeEntityType principalEntityType) { var runtimeForeignKey = declaringEntityType.AddForeignKey(new[] { declaringEntityType.FindProperty("AsId") }, principalEntityType.FindKey(new[] { principalEntityType.FindProperty("AsId") }), principalEntityType, required: true); runtimeForeignKey.AddAnnotation("Relational:Name", "FK_PRZYDZIA_REF_ASPRZ_ASORT"); return runtimeForeignKey; } public static RuntimeForeignKey CreateForeignKey2(RuntimeEntityType declaringEntityType, RuntimeEntityType principalEntityType) { var runtimeForeignKey = declaringEntityType.AddForeignKey(new[] { declaringEntityType.FindProperty("KasaId") }, principalEntityType.FindKey(new[] { principalEntityType.FindProperty("KasaId") }), principalEntityType, required: true); runtimeForeignKey.AddAnnotation("Relational:Name", "FK_PRZYDZIA_REF_KASPR_KASA"); 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", "Przydzial"); runtimeEntityType.AddAnnotation("Relational:ViewName", null); runtimeEntityType.AddAnnotation("Relational:ViewSchema", null); Customize(runtimeEntityType); } static partial void Customize(RuntimeEntityType runtimeEntityType); } }