示例#1
0
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity <Instance>()
            .Property(p => p.Type)
            .HasConversion(x => Instance.InstanceTypeToString(x), x => Instance.StringToInstanceType(x));
            modelBuilder.Entity <Instance>()
            .Property(nameof(Instance.Data))
            .HasConversion(DbContextFactory.CreateJsonValueConverter <InstanceData>());
            modelBuilder.Entity <Instance>()
            .Property(nameof(Instance.Geofences))
            .HasConversion(DbContextFactory.CreateJsonValueConverter <List <string> >());
            modelBuilder.Entity <Geofence>()
            .Property(p => p.Type)
            .HasConversion(x => Geofence.GeofenceTypeToString(x), x => Geofence.StringToGeofenceType(x));
            modelBuilder.Entity <Geofence>()
            .Property(p => p.Data)
            .HasConversion(DbContextFactory.CreateJsonValueConverter <GeofenceData>());
            modelBuilder.Entity <Pokemon>()
            .Property(p => p.PvpRankingsGreatLeague)
            .HasConversion(DbContextFactory.CreateJsonValueConverter <List <dynamic> >());          // TODO: PvpRank
            modelBuilder.Entity <Pokemon>()
            .Property(p => p.PvpRankingsUltraLeague)
            .HasConversion(DbContextFactory.CreateJsonValueConverter <List <dynamic> >());          // TODO: PvpRank
            modelBuilder.Entity <Pokestop>()
            .Property(nameof(Pokestop.QuestConditions))
            .HasConversion(DbContextFactory.CreateJsonValueConverter <List <dynamic> >());
            modelBuilder.Entity <Pokestop>()
            .Property(nameof(Pokestop.QuestRewards))
            .HasConversion(DbContextFactory.CreateJsonValueConverter <List <dynamic> >());
            modelBuilder.Entity <Webhook>()
            .Property(p => p.Types)
            .HasConversion(x => Webhook.WebhookTypeToString(x), x => Webhook.StringToWebhookTypes(x));
            modelBuilder.Entity <Webhook>()
            .Property(nameof(Webhook.Data))
            .HasConversion(DbContextFactory.CreateJsonValueConverter <WebhookData>());
            modelBuilder.Entity <Webhook>()
            .Property(nameof(Webhook.Geofences))
            .HasConversion(DbContextFactory.CreateJsonValueConverter <List <string> >());
            modelBuilder.Entity <DeviceGroup>()
            .Property(nameof(DeviceGroup.Devices))
            .HasConversion(DbContextFactory.CreateJsonValueConverter <List <string> >());
            modelBuilder.Entity <IVList>()
            .Property(nameof(IVList.PokemonIDs))
            .HasConversion(DbContextFactory.CreateJsonValueConverter <List <uint> >());

            base.OnModelCreating(modelBuilder);
        }