Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/04/13 14:57:46 (11 years ago)
Author:
spimming
Message:

#1888:

  • Revised model classes
  • Modified relationship definitions according to model types
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/OaaS/HeuristicLab.Services.Optimization.Billing/DataAccess/BillingContext.cs

    r9577 r9579  
    1313    public DbSet<Invoice> Invoices { get; set; }
    1414    public DbSet<InvoiceLine> InvoiceLines { get; set; }
     15    public DbSet<UsageRecord> UsageRecords { get; set; }
    1516
    1617    // enum PaymentMethod
     
    3334      modelBuilder.Configurations.Add(new InvoiceLineConfiguration());
    3435      modelBuilder.Configurations.Add(new UsageRecordConfiguration());
    35       modelBuilder.Configurations.Add(new UsageRecordLineConfiguration());
    3636
    3737      modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
     
    4545      internal OrderConfiguration() {
    4646        this.HasRequired(o => o.User).WithMany().HasForeignKey(o => o.UserId);
    47         //this.HasMany<Invoice>(o => o.Invoices).WithRequired().HasForeignKey(i => i.OrderId);
    4847        // TODO: OrderState?
    4948      }
     
    5251    private class OrderLineConfiguration : EntityTypeConfiguration<OrderLine> {
    5352      internal OrderLineConfiguration() {
    54         this.HasRequired(ol => ol.Order).WithMany().HasForeignKey(ol => ol.OrderId);
     53        this.HasRequired(ol => ol.Order).WithMany(o => o.OrderLines).HasForeignKey(ol => ol.OrderId).WillCascadeOnDelete(true);
    5554        this.HasRequired(ol => ol.Product).WithMany().HasForeignKey(ol => ol.ProductId);
    5655      }
     
    6059      internal InvoiceConfiguration() {
    6160        this.HasRequired(i => i.User).WithMany().HasForeignKey(i => i.UserId);
    62         this.HasRequired(i => i.Order).WithMany().HasForeignKey(i => i.OrderId);
     61        this.HasRequired(i => i.Order).WithMany(o => o.Invoices).HasForeignKey(i => i.OrderId);
    6362      }
    6463    }
     
    6665    private class InvoiceLineConfiguration : EntityTypeConfiguration<InvoiceLine> {
    6766      internal InvoiceLineConfiguration() {
    68         this.HasRequired(il => il.Invoice).WithMany().HasForeignKey(il => il.InvoiceId);
     67        this.HasRequired(il => il.Invoice).WithMany(i => i.InvoiceLines).HasForeignKey(il => il.InvoiceId).WillCascadeOnDelete(true);
    6968        this.HasRequired(il => il.Product).WithMany().HasForeignKey(il => il.ProductId);
    7069      }
     
    7473      internal UsageRecordConfiguration() {
    7574        this.HasRequired(ur => ur.User).WithMany().HasForeignKey(ur => ur.UserId);
    76       }
    77     }
    78 
    79     private class UsageRecordLineConfiguration : EntityTypeConfiguration<UsageRecordLine> {
    80       internal UsageRecordLineConfiguration() {
    81         this.HasRequired(url => url.UsageRecord).WithMany().HasForeignKey(url => url.UsageRecordId);
     75        this.HasRequired(ur => ur.Product).WithMany().HasForeignKey(ur => ur.ProductId);
    8276      }
    8377    }
Note: See TracChangeset for help on using the changeset viewer.