Changeset 9579


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

#1888:

  • Revised model classes
  • Modified relationship definitions according to model types
Location:
branches/OaaS
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/OaaS/HeuristicLab 3.3 Services.sln

    r9576 r9579  
    377377    {5DC3E4F1-E21B-4C18-8921-88058E86FB07}.Release|x86.ActiveCfg = Release|Any CPU
    378378    {07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Debug|Any CPU.ActiveCfg = Debug|x86
     379    {07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Debug|Any CPU.Build.0 = Debug|x86
    379380    {07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
    380381    {07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Debug|Mixed Platforms.Build.0 = Debug|x86
  • branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/App.config

    r9576 r9579  
    11<?xml version="1.0" encoding="utf-8"?>
    22<configuration>
     3  <configSections>
     4    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
     5    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
     6  </configSections>
    37  <connectionStrings>
    4     <add name="BillingContext" connectionString="ADJUST_ME" providerName="System.Data.SqlClient"/>
     8    <add name="BillingContext" connectionString="ADJUST_ME" providerName="System.Data.SqlClient" />
    59  </connectionStrings>
     10  <entityFramework>
     11    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
     12  </entityFramework>
    613</configuration>
  • branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/HeuristicLab.Services.Optimization.Billing.Test.csproj

    r9576 r9579  
    3535  </PropertyGroup>
    3636  <ItemGroup>
     37    <Reference Include="EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
     38      <HintPath>..\packages\EntityFramework.5.0.0\lib\net40\EntityFramework.dll</HintPath>
     39    </Reference>
    3740    <Reference Include="System" />
     41    <Reference Include="System.ComponentModel.DataAnnotations" />
    3842    <Reference Include="System.Core" />
     43    <Reference Include="System.Data.Entity" />
    3944    <Reference Include="System.Xml.Linq" />
    4045    <Reference Include="System.Data.DataSetExtensions" />
     
    5560  <ItemGroup>
    5661    <None Include="App.config" />
     62    <None Include="packages.config" />
    5763  </ItemGroup>
    5864  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/Program.cs

    r9576 r9579  
    11using System;
    22using HeuristicLab.Services.Optimization.Billing.DataAccess;
     3using HeuristicLab.Services.Optimization.Billing.Model;
    34
    45namespace HeuristicLab.Services.Optimization.Billing.Test {
    56  class Program {
    67    static void Main(string[] args) {
     8      using (var context = new BillingContext()) {
     9        System.Data.Entity.Database.SetInitializer(new HeuristicLab.Services.Optimization.Billing.DataAccess.BillingContext.BillingContextInitiliazer());
     10      }
     11
    712      //BillingService srv = new BillingService();
    813      BillingDao dao = new BillingDao();
    9       dao.FindAllProducts();
     14      var products = dao.FindAllProducts();
     15      foreach (Product p in products) {
     16        Console.WriteLine(string.Format("{0}: {1}", p.ProductId, p.Name));
     17      }
    1018
    1119      Console.WriteLine("Press any key to exit...");
  • 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    }
  • branches/OaaS/HeuristicLab.Services.Optimization.Billing/Model/Model.cs

    r9576 r9579  
    8181    public virtual User User { get; set; }
    8282    public virtual Order Order { get; set; }
     83    public virtual IList<InvoiceLine> InvoiceLines { get; set; }
    8384  }
    8485
     
    9798    public long UsageRecordId { get; set; }
    9899    public long UserId { get; set; }
     100    public long ProductId { get; set; }
     101    public DateTime Begin { get; set; }
     102    public DateTime End { get; set; }
     103    public int ServiceIdentifier { get; set; }
     104    public int ResourceIdentifier { get; set; }
    99105
    100106    public virtual User User { get; set; }
    101     public virtual IList<UsageRecordLine> UsageRecordLines { get; set; }
    102   }
    103 
    104   public class UsageRecordLine {
    105     public long UsageRecordLineId { get; set; }
    106     public long UsageRecordId { get; set; }
    107     public DateTime Begin { get; set; }
    108     public DateTime End { get; set; }
    109 
    110     public virtual UsageRecord UsageRecord { get; set; }
     107    public virtual Product Product { get; set; }
    111108  }
    112109}
Note: See TracChangeset for help on using the changeset viewer.