コード例 #1
0
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            var converter = new ValueConverter <TransactionCategoryType, string>(
                v => v.Value,
                v => TransactionCategoryType.FromString(v));

            modelBuilder.Entity <Wallet>()
            .HasOne <User>()
            .WithMany()
            .HasForeignKey(wallet => wallet.UserId);


            modelBuilder.Entity <Transaction>()
            .HasOne <User>()
            .WithMany()
            .HasForeignKey(transaction => transaction.UserId);

            modelBuilder.Entity <Transaction>()
            .HasOne <Wallet>()
            .WithMany()
            .HasForeignKey(transaction => transaction.WalletId);

            modelBuilder.Entity <TransactionCategory>()
            .HasOne <User>()
            .WithMany()
            .HasForeignKey(transaction => transaction.UserId);
            modelBuilder.Entity <TransactionCategory>()
            .Property(c => c.Type)
            .HasConversion(converter);
            base.OnModelCreating(modelBuilder);
        }
コード例 #2
0
 public TransactionCategory(
     string name,
     string iconName,
     TransactionCategoryType type,
     int userId)
 {
     this.Name     = name;
     this.IconName = iconName;
     this.Type     = type;
     this.UserId   = userId;
 }