Changeset 9579
- Timestamp:
- 06/04/13 14:57:46 (12 years ago)
- Location:
- branches/OaaS
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS/HeuristicLab 3.3 Services.sln
r9576 r9579 377 377 {5DC3E4F1-E21B-4C18-8921-88058E86FB07}.Release|x86.ActiveCfg = Release|Any CPU 378 378 {07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Debug|Any CPU.ActiveCfg = Debug|x86 379 {07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Debug|Any CPU.Build.0 = Debug|x86 379 380 {07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 380 381 {07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Debug|Mixed Platforms.Build.0 = Debug|x86 -
branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/App.config
r9576 r9579 1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <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> 3 7 <connectionStrings> 4 <add name="BillingContext" connectionString="ADJUST_ME" providerName="System.Data.SqlClient" />8 <add name="BillingContext" connectionString="ADJUST_ME" providerName="System.Data.SqlClient" /> 5 9 </connectionStrings> 10 <entityFramework> 11 <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> 12 </entityFramework> 6 13 </configuration> -
branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/HeuristicLab.Services.Optimization.Billing.Test.csproj
r9576 r9579 35 35 </PropertyGroup> 36 36 <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> 37 40 <Reference Include="System" /> 41 <Reference Include="System.ComponentModel.DataAnnotations" /> 38 42 <Reference Include="System.Core" /> 43 <Reference Include="System.Data.Entity" /> 39 44 <Reference Include="System.Xml.Linq" /> 40 45 <Reference Include="System.Data.DataSetExtensions" /> … … 55 60 <ItemGroup> 56 61 <None Include="App.config" /> 62 <None Include="packages.config" /> 57 63 </ItemGroup> 58 64 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/Program.cs
r9576 r9579 1 1 using System; 2 2 using HeuristicLab.Services.Optimization.Billing.DataAccess; 3 using HeuristicLab.Services.Optimization.Billing.Model; 3 4 4 5 namespace HeuristicLab.Services.Optimization.Billing.Test { 5 6 class Program { 6 7 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 7 12 //BillingService srv = new BillingService(); 8 13 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 } 10 18 11 19 Console.WriteLine("Press any key to exit..."); -
branches/OaaS/HeuristicLab.Services.Optimization.Billing/DataAccess/BillingContext.cs
r9577 r9579 13 13 public DbSet<Invoice> Invoices { get; set; } 14 14 public DbSet<InvoiceLine> InvoiceLines { get; set; } 15 public DbSet<UsageRecord> UsageRecords { get; set; } 15 16 16 17 // enum PaymentMethod … … 33 34 modelBuilder.Configurations.Add(new InvoiceLineConfiguration()); 34 35 modelBuilder.Configurations.Add(new UsageRecordConfiguration()); 35 modelBuilder.Configurations.Add(new UsageRecordLineConfiguration());36 36 37 37 modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>(); … … 45 45 internal OrderConfiguration() { 46 46 this.HasRequired(o => o.User).WithMany().HasForeignKey(o => o.UserId); 47 //this.HasMany<Invoice>(o => o.Invoices).WithRequired().HasForeignKey(i => i.OrderId);48 47 // TODO: OrderState? 49 48 } … … 52 51 private class OrderLineConfiguration : EntityTypeConfiguration<OrderLine> { 53 52 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); 55 54 this.HasRequired(ol => ol.Product).WithMany().HasForeignKey(ol => ol.ProductId); 56 55 } … … 60 59 internal InvoiceConfiguration() { 61 60 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); 63 62 } 64 63 } … … 66 65 private class InvoiceLineConfiguration : EntityTypeConfiguration<InvoiceLine> { 67 66 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); 69 68 this.HasRequired(il => il.Product).WithMany().HasForeignKey(il => il.ProductId); 70 69 } … … 74 73 internal UsageRecordConfiguration() { 75 74 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); 82 76 } 83 77 } -
branches/OaaS/HeuristicLab.Services.Optimization.Billing/Model/Model.cs
r9576 r9579 81 81 public virtual User User { get; set; } 82 82 public virtual Order Order { get; set; } 83 public virtual IList<InvoiceLine> InvoiceLines { get; set; } 83 84 } 84 85 … … 97 98 public long UsageRecordId { get; set; } 98 99 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; } 99 105 100 106 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; } 111 108 } 112 109 }
Note: See TracChangeset
for help on using the changeset viewer.