private static void SetEntityProperties(RuntimeEntityType entityType, ResourceType resourceType)
 {
     foreach (PropertyInfo property in resourceType.ClrType.GetProperties().Where(property => !IsIgnored(property)))
     {
         entityType.AddProperty(property.Name, property.PropertyType, property);
     }
 }
Esempio n. 2
0
        public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType baseEntityType = null)
        {
            var runtimeEntityType = model.AddEntityType(
                "BlazingPizza.Topping",
                typeof(Topping),
                baseEntityType);

            var id = runtimeEntityType.AddProperty(
                "Id",
                typeof(int),
                propertyInfo: typeof(Topping).GetProperty("Id", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(Topping).GetField("<Id>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                valueGenerated: ValueGenerated.OnAdd,
                afterSaveBehavior: PropertySaveBehavior.Throw);

            var name = runtimeEntityType.AddProperty(
                "Name",
                typeof(string),
                propertyInfo: typeof(Topping).GetProperty("Name", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(Topping).GetField("<Name>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                nullable: true);

            var price = runtimeEntityType.AddProperty(
                "Price",
                typeof(decimal),
                propertyInfo: typeof(Topping).GetProperty("Price", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(Topping).GetField("<Price>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));

            var key = runtimeEntityType.AddKey(
                new[] { id });

            runtimeEntityType.SetPrimaryKey(key);

            return(runtimeEntityType);
        }
        public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType baseEntityType = null)
        {
            var runtimeEntityType = model.AddEntityType(
                "BlazingPizza.PizzaTopping",
                typeof(PizzaTopping),
                baseEntityType);

            var pizzaId = runtimeEntityType.AddProperty(
                "PizzaId",
                typeof(int),
                propertyInfo: typeof(PizzaTopping).GetProperty("PizzaId", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(PizzaTopping).GetField("<PizzaId>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                afterSaveBehavior: PropertySaveBehavior.Throw);

            var toppingId = runtimeEntityType.AddProperty(
                "ToppingId",
                typeof(int),
                propertyInfo: typeof(PizzaTopping).GetProperty("ToppingId", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(PizzaTopping).GetField("<ToppingId>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                afterSaveBehavior: PropertySaveBehavior.Throw);

            var key = runtimeEntityType.AddKey(
                new[] { pizzaId, toppingId });

            runtimeEntityType.SetPrimaryKey(key);

            var index = runtimeEntityType.AddIndex(
                new[] { toppingId });

            return(runtimeEntityType);
        }
        public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType baseEntityType = null)
        {
            var runtimeEntityType = model.AddEntityType(
                "OpenBudget.Model.Entities.TransactionSnapshot.Parent#EntityReference",
                typeof(EntityReference),
                baseEntityType,
                sharedClrType: true);

            var transactionSnapshotEntityID = runtimeEntityType.AddProperty(
                "TransactionSnapshotEntityID",
                typeof(string),
                afterSaveBehavior: PropertySaveBehavior.Throw);

            var entityID = runtimeEntityType.AddProperty(
                "EntityID",
                typeof(string),
                propertyInfo: typeof(EntityReference).GetProperty("EntityID", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(EntityReference).GetField("<EntityID>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                nullable: true);

            var entityType = runtimeEntityType.AddProperty(
                "EntityType",
                typeof(string),
                propertyInfo: typeof(EntityReference).GetProperty("EntityType", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(EntityReference).GetField("<EntityType>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                nullable: true);

            var key = runtimeEntityType.AddKey(
                new[] { transactionSnapshotEntityID });

            runtimeEntityType.SetPrimaryKey(key);

            return(runtimeEntityType);
        }
        public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType baseEntityType = null)
        {
            var runtimeEntityType = model.AddEntityType(
                "Microsoft.AspNetCore.Identity.IdentityUserRole<string>",
                typeof(IdentityUserRole <string>),
                baseEntityType);

            var userId = runtimeEntityType.AddProperty(
                "UserId",
                typeof(string),
                propertyInfo: typeof(IdentityUserRole <string>).GetProperty("UserId", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(IdentityUserRole <string>).GetField("<UserId>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                afterSaveBehavior: PropertySaveBehavior.Throw);

            var roleId = runtimeEntityType.AddProperty(
                "RoleId",
                typeof(string),
                propertyInfo: typeof(IdentityUserRole <string>).GetProperty("RoleId", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(IdentityUserRole <string>).GetField("<RoleId>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                afterSaveBehavior: PropertySaveBehavior.Throw);

            var key = runtimeEntityType.AddKey(
                new[] { userId, roleId });

            runtimeEntityType.SetPrimaryKey(key);

            var index = runtimeEntityType.AddIndex(
                new[] { roleId });

            return(runtimeEntityType);
        }
Esempio n. 6
0
        public static void CreateAnnotations(RuntimeEntityType runtimeEntityType)
        {
            runtimeEntityType.AddAnnotation("Relational:Schema", null);
            runtimeEntityType.AddAnnotation("Relational:TableName", "AspNetUsers");

            Customize(runtimeEntityType);
        }
Esempio n. 7
0
        public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType baseEntityType = null)
        {
            var runtimeEntityType = model.AddEntityType(
                "BlazingPizza.LatLong",
                typeof(LatLong),
                baseEntityType);

            var orderId = runtimeEntityType.AddProperty(
                "OrderId",
                typeof(int),
                afterSaveBehavior: PropertySaveBehavior.Throw);

            var latitude = runtimeEntityType.AddProperty(
                "Latitude",
                typeof(double),
                propertyInfo: typeof(LatLong).GetProperty("Latitude", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(LatLong).GetField("<Latitude>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));

            var longitude = runtimeEntityType.AddProperty(
                "Longitude",
                typeof(double),
                propertyInfo: typeof(LatLong).GetProperty("Longitude", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(LatLong).GetField("<Longitude>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));

            var key = runtimeEntityType.AddKey(
                new[] { orderId });

            runtimeEntityType.SetPrimaryKey(key);

            return(runtimeEntityType);
        }
Esempio n. 8
0
        public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType baseEntityType = null)
        {
            var runtimeEntityType = model.AddEntityType(
                "Anf.ChannelModel.Entity.AnfSearchCount",
                typeof(AnfSearchCount),
                baseEntityType);

            var id = runtimeEntityType.AddProperty(
                "Id",
                typeof(ulong),
                propertyInfo: typeof(AnfCount).GetProperty("Id", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(AnfCount).GetField("<Id>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                valueGenerated: ValueGenerated.OnAdd,
                afterSaveBehavior: PropertySaveBehavior.Throw);

            var content = runtimeEntityType.AddProperty(
                "Content",
                typeof(string),
                propertyInfo: typeof(AnfSearchCount).GetProperty("Content", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(AnfSearchCount).GetField("<Content>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                maxLength: 250);

            var iP = runtimeEntityType.AddProperty(
                "IP",
                typeof(string),
                propertyInfo: typeof(AnfCount).GetProperty("IP", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(AnfCount).GetField("<IP>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                nullable: true,
                maxLength: 36);

            var time = runtimeEntityType.AddProperty(
                "Time",
                typeof(DateTime),
                propertyInfo: typeof(AnfCount).GetProperty("Time", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(AnfCount).GetField("<Time>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));

            var userId = runtimeEntityType.AddProperty(
                "UserId",
                typeof(long?),
                propertyInfo: typeof(AnfSearchCount).GetProperty("UserId", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(AnfSearchCount).GetField("<UserId>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                nullable: true);

            var key = runtimeEntityType.AddKey(
                new[] { id });

            runtimeEntityType.SetPrimaryKey(key);

            var index = runtimeEntityType.AddIndex(
                new[] { content });

            var index0 = runtimeEntityType.AddIndex(
                new[] { time });

            var index1 = runtimeEntityType.AddIndex(
                new[] { userId });

            return(runtimeEntityType);
        }
Esempio n. 9
0
        public RuntimeProperty(
            string name,
            Type clrType,
            PropertyInfo?propertyInfo,
            FieldInfo?fieldInfo,
            RuntimeEntityType declaringEntityType,
            PropertyAccessMode propertyAccessMode,
            bool nullable,
            bool concurrencyToken,
            ValueGenerated valueGenerated,
            PropertySaveBehavior beforeSaveBehavior,
            PropertySaveBehavior afterSaveBehavior,
            int?maxLength,
            bool?unicode,
            int?precision,
            int?scale,
            Type?providerClrType,
            Func <IProperty, IEntityType, ValueGenerator>?valueGeneratorFactory,
            ValueConverter?valueConverter,
            ValueComparer?valueComparer,
            ValueComparer?keyValueComparer,
            CoreTypeMapping?typeMapping)
            : base(name, propertyInfo, fieldInfo, propertyAccessMode)
        {
            DeclaringEntityType    = declaringEntityType;
            ClrType                = clrType;
            _isNullable            = nullable;
            _isConcurrencyToken    = concurrencyToken;
            _valueGenerated        = valueGenerated;
            _beforeSaveBehavior    = beforeSaveBehavior;
            _afterSaveBehavior     = afterSaveBehavior;
            _valueGeneratorFactory = valueGeneratorFactory;
            _valueConverter        = valueConverter;

            if (maxLength != null)
            {
                SetAnnotation(CoreAnnotationNames.MaxLength, maxLength);
            }
            if (unicode != null)
            {
                SetAnnotation(CoreAnnotationNames.Unicode, unicode);
            }
            if (precision != null)
            {
                SetAnnotation(CoreAnnotationNames.Precision, precision);
            }
            if (scale != null)
            {
                SetAnnotation(CoreAnnotationNames.Scale, scale);
            }
            if (providerClrType != null)
            {
                SetAnnotation(CoreAnnotationNames.ProviderClrType, providerClrType);
            }

            _typeMapping      = typeMapping;
            _valueComparer    = valueComparer;
            _keyValueComparer = keyValueComparer ?? valueComparer;
        }
Esempio n. 10
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="RuntimeCheckConstraint"/> class.
 /// </summary>
 /// <param name="name"> The constraint name. </param>
 /// <param name="entityType"> The affected entity type. </param>
 /// <param name="sql"> The SQL string. </param>
 public RuntimeCheckConstraint(
     string name,
     RuntimeEntityType entityType,
     string sql)
 {
     EntityType = entityType;
     Name       = name;
     Sql        = sql;
 }
    public MongoModel(IResourceGraph resourceGraph)
    {
        ArgumentGuard.NotNull(resourceGraph, nameof(resourceGraph));

        foreach (ResourceType resourceType in resourceGraph.GetResourceTypes())
        {
            RuntimeEntityType entityType = AddEntityType(resourceType.ClrType.FullName !, resourceType.ClrType);
            SetEntityProperties(entityType, resourceType);
        }
    }
        public static RuntimeForeignKey CreateForeignKey2(RuntimeEntityType declaringEntityType, RuntimeEntityType principalEntityType)
        {
            var runtimeForeignKey = declaringEntityType.AddForeignKey(new[] { declaringEntityType.FindProperty("UserId") },
                                                                      principalEntityType.FindKey(new[] { principalEntityType.FindProperty("Id") }),
                                                                      principalEntityType,
                                                                      deleteBehavior: DeleteBehavior.Cascade,
                                                                      required: true);

            return(runtimeForeignKey);
        }
        public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType baseEntityType = null)
        {
            var runtimeEntityType = model.AddEntityType(
                "OpenBudget.Model.Entities.MasterCategorySnapshot",
                typeof(MasterCategorySnapshot),
                baseEntityType);

            var entityID = runtimeEntityType.AddProperty(
                "EntityID",
                typeof(string),
                propertyInfo: typeof(EntitySnapshot).GetProperty("EntityID", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(EntitySnapshot).GetField("<EntityID>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                afterSaveBehavior: PropertySaveBehavior.Throw);

            var isDeleted = runtimeEntityType.AddProperty(
                "IsDeleted",
                typeof(bool),
                propertyInfo: typeof(EntitySnapshot).GetProperty("IsDeleted", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(EntitySnapshot).GetField("<IsDeleted>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));

            var lastEventID = runtimeEntityType.AddProperty(
                "LastEventID",
                typeof(string),
                propertyInfo: typeof(EntitySnapshot).GetProperty("LastEventID", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(EntitySnapshot).GetField("<LastEventID>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                nullable: true);

            var lastEventVector = runtimeEntityType.AddProperty(
                "LastEventVector",
                typeof(VectorClock),
                propertyInfo: typeof(EntitySnapshot).GetProperty("LastEventVector", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(EntitySnapshot).GetField("<LastEventVector>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                nullable: true,
                valueConverter: new VectorClockConverter());

            var name = runtimeEntityType.AddProperty(
                "Name",
                typeof(string),
                propertyInfo: typeof(MasterCategorySnapshot).GetProperty("Name", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(MasterCategorySnapshot).GetField("<Name>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                nullable: true);

            var sortOrder = runtimeEntityType.AddProperty(
                "SortOrder",
                typeof(int),
                propertyInfo: typeof(MasterCategorySnapshot).GetProperty("SortOrder", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(MasterCategorySnapshot).GetField("<SortOrder>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));

            var key = runtimeEntityType.AddKey(
                new[] { entityID });

            runtimeEntityType.SetPrimaryKey(key);

            return(runtimeEntityType);
        }
Esempio n. 14
0
 public RuntimeIndex(
     IReadOnlyList <RuntimeProperty> properties,
     RuntimeEntityType declaringEntityType,
     string?name,
     bool unique)
 {
     Properties          = properties;
     Name                = name;
     DeclaringEntityType = declaringEntityType;
     _isUnique           = unique;
 }
Esempio n. 15
0
        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", "Specials");
            runtimeEntityType.AddAnnotation("Relational:ViewName", null);
            runtimeEntityType.AddAnnotation("Relational:ViewSchema", null);

            Customize(runtimeEntityType);
        }
Esempio n. 16
0
        protected override void ProcessEntityTypeAnnotations(
            IDictionary <string, object?> annotations, IEntityType entityType, RuntimeEntityType runtimeEntityType, bool runtime)
        {
            base.ProcessEntityTypeAnnotations(annotations, entityType, runtimeEntityType, runtime);

            if (!runtime)
            {
                annotations.Remove(CosmosAnnotationNames.AnalyticalStoreTimeToLive);
                annotations.Remove(CosmosAnnotationNames.DefaultTimeToLive);
                annotations.Remove(CosmosAnnotationNames.Throughput);
            }
        }
Esempio n. 17
0
        public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType baseEntityType = null)
        {
            var runtimeEntityType = model.AddEntityType(
                "Anf.ChannelModel.Entity.AnfRole",
                typeof(AnfRole),
                baseEntityType);

            var id = runtimeEntityType.AddProperty(
                "Id",
                typeof(long),
                propertyInfo: typeof(IdentityRole <long>).GetProperty("Id", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(IdentityRole <long>).GetField("<Id>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                valueGenerated: ValueGenerated.OnAdd,
                afterSaveBehavior: PropertySaveBehavior.Throw);

            var concurrencyStamp = runtimeEntityType.AddProperty(
                "ConcurrencyStamp",
                typeof(string),
                propertyInfo: typeof(IdentityRole <long>).GetProperty("ConcurrencyStamp", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(IdentityRole <long>).GetField("<ConcurrencyStamp>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                nullable: true,
                concurrencyToken: true);

            var name = runtimeEntityType.AddProperty(
                "Name",
                typeof(string),
                propertyInfo: typeof(IdentityRole <long>).GetProperty("Name", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(IdentityRole <long>).GetField("<Name>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                nullable: true,
                maxLength: 256);

            var normalizedName = runtimeEntityType.AddProperty(
                "NormalizedName",
                typeof(string),
                propertyInfo: typeof(IdentityRole <long>).GetProperty("NormalizedName", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(IdentityRole <long>).GetField("<NormalizedName>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                nullable: true,
                maxLength: 256);

            var key = runtimeEntityType.AddKey(
                new[] { id });

            runtimeEntityType.SetPrimaryKey(key);

            var index = runtimeEntityType.AddIndex(
                new[] { normalizedName },
                unique: true);

            index.AddAnnotation("Relational:Name", "RoleNameIndex");

            return(runtimeEntityType);
        }
Esempio n. 18
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public RuntimeTrigger(
     RuntimeEntityType entityType,
     string modelName,
     string?name,
     string tableName,
     string?tableSchema)
 {
     EntityType  = entityType;
     ModelName   = modelName;
     Name        = name;
     TableName   = tableName;
     TableSchema = tableSchema;
 }
Esempio n. 19
0
        public RuntimeServiceProperty(
            string name,
            PropertyInfo?propertyInfo,
            FieldInfo?fieldInfo,
            RuntimeEntityType declaringEntityType,
            PropertyAccessMode propertyAccessMode)
            : base(name, propertyInfo, fieldInfo, propertyAccessMode)
        {
            Check.NotNull(declaringEntityType, nameof(declaringEntityType));

            DeclaringEntityType = declaringEntityType;
            ClrType             = (propertyInfo?.PropertyType ?? fieldInfo?.FieldType) !;
        }
        public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType baseEntityType = null)
        {
            var runtimeEntityType = model.AddEntityType(
                "BlazingPizza.NotificationSubscription",
                typeof(NotificationSubscription),
                baseEntityType);

            var notificationSubscriptionId = runtimeEntityType.AddProperty(
                "NotificationSubscriptionId",
                typeof(int),
                propertyInfo: typeof(NotificationSubscription).GetProperty("NotificationSubscriptionId", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(NotificationSubscription).GetField("<NotificationSubscriptionId>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                valueGenerated: ValueGenerated.OnAdd,
                afterSaveBehavior: PropertySaveBehavior.Throw);

            var auth = runtimeEntityType.AddProperty(
                "Auth",
                typeof(string),
                propertyInfo: typeof(NotificationSubscription).GetProperty("Auth", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(NotificationSubscription).GetField("<Auth>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                nullable: true);

            var p256dh = runtimeEntityType.AddProperty(
                "P256dh",
                typeof(string),
                propertyInfo: typeof(NotificationSubscription).GetProperty("P256dh", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(NotificationSubscription).GetField("<P256dh>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                nullable: true);

            var url = runtimeEntityType.AddProperty(
                "Url",
                typeof(string),
                propertyInfo: typeof(NotificationSubscription).GetProperty("Url", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(NotificationSubscription).GetField("<Url>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                nullable: true);

            var userId = runtimeEntityType.AddProperty(
                "UserId",
                typeof(string),
                propertyInfo: typeof(NotificationSubscription).GetProperty("UserId", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(NotificationSubscription).GetField("<UserId>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                nullable: true);

            var key = runtimeEntityType.AddKey(
                new[] { notificationSubscriptionId });

            runtimeEntityType.SetPrimaryKey(key);

            return(runtimeEntityType);
        }
Esempio n. 21
0
        public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType baseEntityType = null)
        {
            var runtimeEntityType = model.AddEntityType(
                "Anf.ChannelModel.Entity.AnfWorkReadStatistic",
                typeof(AnfWorkReadStatistic),
                baseEntityType);

            var id = runtimeEntityType.AddProperty(
                "Id",
                typeof(ulong),
                propertyInfo: typeof(AnfStatistic).GetProperty("Id", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(AnfStatistic).GetField("<Id>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                valueGenerated: ValueGenerated.OnAdd,
                afterSaveBehavior: PropertySaveBehavior.Throw);

            var count = runtimeEntityType.AddProperty(
                "Count",
                typeof(long),
                propertyInfo: typeof(AnfStatistic).GetProperty("Count", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(AnfStatistic).GetField("<Count>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));

            var time = runtimeEntityType.AddProperty(
                "Time",
                typeof(DateTime),
                propertyInfo: typeof(AnfStatistic).GetProperty("Time", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(AnfStatistic).GetField("<Time>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));

            var type = runtimeEntityType.AddProperty(
                "Type",
                typeof(StatisticLevels),
                propertyInfo: typeof(AnfStatistic).GetProperty("Type", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(AnfStatistic).GetField("<Type>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));

            var wordId = runtimeEntityType.AddProperty(
                "WordId",
                typeof(ulong),
                propertyInfo: typeof(AnfWorkReadStatistic).GetProperty("WordId", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(AnfWorkReadStatistic).GetField("<WordId>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));

            var key = runtimeEntityType.AddKey(
                new[] { id });

            runtimeEntityType.SetPrimaryKey(key);

            var index = runtimeEntityType.AddIndex(
                new[] { wordId });

            return(runtimeEntityType);
        }
Esempio n. 22
0
        public static RuntimeForeignKey CreateForeignKey1(RuntimeEntityType declaringEntityType, RuntimeEntityType principalEntityType)
        {
            var runtimeForeignKey = declaringEntityType.AddForeignKey(new[] { declaringEntityType.FindProperty("AuthorId") },
                                                                      principalEntityType.FindKey(new[] { principalEntityType.FindProperty("Id") }),
                                                                      principalEntityType);

            var author = declaringEntityType.AddNavigation("Author",
                                                           runtimeForeignKey,
                                                           onDependent: true,
                                                           typeof(AnfUser),
                                                           propertyInfo: typeof(AnfWord).GetProperty("Author", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                                                           fieldInfo: typeof(AnfWord).GetField("<Author>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));

            return(runtimeForeignKey);
        }
Esempio n. 23
0
        public static RuntimeForeignKey CreateForeignKey1(RuntimeEntityType declaringEntityType, RuntimeEntityType principalEntityType)
        {
            var runtimeForeignKey = declaringEntityType.AddForeignKey(new[] { declaringEntityType.FindProperty("DeliveryAddressId") },
                                                                      principalEntityType.FindKey(new[] { principalEntityType.FindProperty("Id") }),
                                                                      principalEntityType);

            var deliveryAddress = declaringEntityType.AddNavigation("DeliveryAddress",
                                                                    runtimeForeignKey,
                                                                    onDependent: true,
                                                                    typeof(Address),
                                                                    propertyInfo: typeof(Order).GetProperty("DeliveryAddress", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                                                                    fieldInfo: typeof(Order).GetField("<DeliveryAddress>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));

            return(runtimeForeignKey);
        }
Esempio n. 24
0
    /// <inheritdoc />
    protected override void ProcessEntityTypeAnnotations(
        IDictionary <string, object?> annotations, IEntityType entityType, RuntimeEntityType runtimeEntityType, bool runtime)
    {
        base.ProcessEntityTypeAnnotations(annotations, entityType, runtimeEntityType, runtime);

        if (!runtime)
        {
            annotations.Remove(NpgsqlAnnotationNames.UnloggedTable);

            foreach (var annotationName in annotations.Keys.Where(
                         k => k.StartsWith(NpgsqlAnnotationNames.StorageParameterPrefix, StringComparison.Ordinal)))
            {
                annotations.Remove(annotationName);
            }
        }
    }
Esempio n. 25
0
        public static RuntimeForeignKey CreateForeignKey1(RuntimeEntityType declaringEntityType, RuntimeEntityType principalEntityType)
        {
            var runtimeForeignKey = declaringEntityType.AddForeignKey(new[] { declaringEntityType.FindProperty("UserId") },
                                                                      principalEntityType.FindKey(new[] { principalEntityType.FindProperty("Id") }),
                                                                      principalEntityType,
                                                                      deleteBehavior: DeleteBehavior.Cascade,
                                                                      required: true);

            var user = declaringEntityType.AddNavigation("User",
                                                         runtimeForeignKey,
                                                         onDependent: true,
                                                         typeof(AnfUser),
                                                         propertyInfo: typeof(AnfWordUserStatistic).GetProperty("User", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                                                         fieldInfo: typeof(AnfWordUserStatistic).GetField("<User>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));

            return(runtimeForeignKey);
        }
Esempio n. 26
0
        public static RuntimeForeignKey CreateForeignKey2(RuntimeEntityType declaringEntityType, RuntimeEntityType principalEntityType)
        {
            var runtimeForeignKey = declaringEntityType.AddForeignKey(new[] { declaringEntityType.FindProperty("SpecialId") },
                                                                      principalEntityType.FindKey(new[] { principalEntityType.FindProperty("Id") }),
                                                                      principalEntityType,
                                                                      deleteBehavior: DeleteBehavior.Cascade,
                                                                      required: true);

            var special = declaringEntityType.AddNavigation("Special",
                                                            runtimeForeignKey,
                                                            onDependent: true,
                                                            typeof(PizzaSpecial),
                                                            propertyInfo: typeof(Pizza).GetProperty("Special", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                                                            fieldInfo: typeof(Pizza).GetField("<Special>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));

            return(runtimeForeignKey);
        }
Esempio n. 27
0
        public static RuntimeForeignKey CreateForeignKey1(RuntimeEntityType declaringEntityType, RuntimeEntityType principalEntityType)
        {
            var runtimeForeignKey = declaringEntityType.AddForeignKey(new[] { declaringEntityType.FindProperty("OrderId") },
                                                                      principalEntityType.FindKey(new[] { principalEntityType.FindProperty("OrderId") }),
                                                                      principalEntityType,
                                                                      deleteBehavior: DeleteBehavior.Cascade,
                                                                      required: true);

            var pizzas = principalEntityType.AddNavigation("Pizzas",
                                                           runtimeForeignKey,
                                                           onDependent: false,
                                                           typeof(List <Pizza>),
                                                           propertyInfo: typeof(Order).GetProperty("Pizzas", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                                                           fieldInfo: typeof(Order).GetField("<Pizzas>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));

            return(runtimeForeignKey);
        }
Esempio n. 28
0
        public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType baseEntityType = null)
        {
            var runtimeEntityType = model.AddEntityType(
                "BlazingPizza.Pizza",
                typeof(Pizza),
                baseEntityType);

            var id = runtimeEntityType.AddProperty(
                "Id",
                typeof(int),
                propertyInfo: typeof(Pizza).GetProperty("Id", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(Pizza).GetField("<Id>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                valueGenerated: ValueGenerated.OnAdd,
                afterSaveBehavior: PropertySaveBehavior.Throw);

            var orderId = runtimeEntityType.AddProperty(
                "OrderId",
                typeof(int),
                propertyInfo: typeof(Pizza).GetProperty("OrderId", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(Pizza).GetField("<OrderId>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));

            var size = runtimeEntityType.AddProperty(
                "Size",
                typeof(int),
                propertyInfo: typeof(Pizza).GetProperty("Size", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(Pizza).GetField("<Size>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));

            var specialId = runtimeEntityType.AddProperty(
                "SpecialId",
                typeof(int),
                propertyInfo: typeof(Pizza).GetProperty("SpecialId", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(Pizza).GetField("<SpecialId>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));

            var key = runtimeEntityType.AddKey(
                new[] { id });

            runtimeEntityType.SetPrimaryKey(key);

            var index = runtimeEntityType.AddIndex(
                new[] { orderId });

            var index0 = runtimeEntityType.AddIndex(
                new[] { specialId });

            return(runtimeEntityType);
        }
Esempio n. 29
0
        public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType baseEntityType = null)
        {
            var runtimeEntityType = model.AddEntityType(
                "Microsoft.AspNetCore.Identity.IdentityUserLogin<string>",
                typeof(IdentityUserLogin <string>),
                baseEntityType);

            var loginProvider = runtimeEntityType.AddProperty(
                "LoginProvider",
                typeof(string),
                propertyInfo: typeof(IdentityUserLogin <string>).GetProperty("LoginProvider", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(IdentityUserLogin <string>).GetField("<LoginProvider>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                afterSaveBehavior: PropertySaveBehavior.Throw,
                maxLength: 128);

            var providerKey = runtimeEntityType.AddProperty(
                "ProviderKey",
                typeof(string),
                propertyInfo: typeof(IdentityUserLogin <string>).GetProperty("ProviderKey", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(IdentityUserLogin <string>).GetField("<ProviderKey>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                afterSaveBehavior: PropertySaveBehavior.Throw,
                maxLength: 128);

            var providerDisplayName = runtimeEntityType.AddProperty(
                "ProviderDisplayName",
                typeof(string),
                propertyInfo: typeof(IdentityUserLogin <string>).GetProperty("ProviderDisplayName", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(IdentityUserLogin <string>).GetField("<ProviderDisplayName>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                nullable: true);

            var userId = runtimeEntityType.AddProperty(
                "UserId",
                typeof(string),
                propertyInfo: typeof(IdentityUserLogin <string>).GetProperty("UserId", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(IdentityUserLogin <string>).GetField("<UserId>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));

            var key = runtimeEntityType.AddKey(
                new[] { loginProvider, providerKey });

            runtimeEntityType.SetPrimaryKey(key);

            var index = runtimeEntityType.AddIndex(
                new[] { userId });

            return(runtimeEntityType);
        }
        public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType baseEntityType = null)
        {
            var runtimeEntityType = model.AddEntityType(
                "Microsoft.AspNetCore.Identity.IdentityUserClaim<string>",
                typeof(IdentityUserClaim <string>),
                baseEntityType);

            var id = runtimeEntityType.AddProperty(
                "Id",
                typeof(int),
                propertyInfo: typeof(IdentityUserClaim <string>).GetProperty("Id", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(IdentityUserClaim <string>).GetField("<Id>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                valueGenerated: ValueGenerated.OnAdd,
                afterSaveBehavior: PropertySaveBehavior.Throw);

            var claimType = runtimeEntityType.AddProperty(
                "ClaimType",
                typeof(string),
                propertyInfo: typeof(IdentityUserClaim <string>).GetProperty("ClaimType", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(IdentityUserClaim <string>).GetField("<ClaimType>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                nullable: true);

            var claimValue = runtimeEntityType.AddProperty(
                "ClaimValue",
                typeof(string),
                propertyInfo: typeof(IdentityUserClaim <string>).GetProperty("ClaimValue", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(IdentityUserClaim <string>).GetField("<ClaimValue>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                nullable: true);

            var userId = runtimeEntityType.AddProperty(
                "UserId",
                typeof(string),
                propertyInfo: typeof(IdentityUserClaim <string>).GetProperty("UserId", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
                fieldInfo: typeof(IdentityUserClaim <string>).GetField("<UserId>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly));

            var key = runtimeEntityType.AddKey(
                new[] { id });

            runtimeEntityType.SetPrimaryKey(key);

            var index = runtimeEntityType.AddIndex(
                new[] { userId });

            return(runtimeEntityType);
        }