Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/19/13 15:25:31 (11 years ago)
Author:
spimming
Message:

#1888:

  • Model classes implement new interface to track current state of entity
  • Mark EntityState property as 'not mapped'
  • Set hook to initialize entity as unchanged
  • Extension method for DbContext to apply changes only on modified entity
File:
1 edited

Legend:

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

    r9641 r9645  
    22using System;
    33using System.Collections.Generic;
     4using HeuristicLab.Services.Optimization.Billing.Interfaces;
    45namespace HeuristicLab.Services.Optimization.Billing.Model {
    56
     
    1415   */
    1516
    16   public class ContactInformation {
     17  public class ContactInformation : IObjectWithState {
    1718    public long ContactInformationId { get; set; }
    1819    public string OrganizationName { get; set; }
     
    2425    public string FirstName { get; set; }
    2526    public string Email { get; set; }
     27
     28    // Property is not mapped
     29    // It is used to track state (disconnected entities)
     30    public State EntityState { get; set; }
    2631  }
    2732
    28   public class PaymentInformation {
     33  public class PaymentInformation : IObjectWithState {
    2934    public long PaymentInformationId { get; set; }
    3035    public long UserId { get; set; }
     
    3944      set { PaymentMethodValue = (int)value; }
    4045    }
     46
     47    public State EntityState { get; set; }
    4148  }
    4249
     
    6067  }
    6168
    62   public class Product {
     69  public class Product : IObjectWithState {
    6370    public long ProductId { get; set; }
    6471    public string Name { get; set; }
     
    6673    public string ProductType { get; set; }
    6774    public double Price { get; set; }
     75
     76    public State EntityState { get; set; }
    6877  }
    6978
    70   public class User {
     79  public class User : IObjectWithState {
    7180    public long UserId { get; set; }
    7281    public long ContactInformationId { get; set; }
     
    7584    public virtual IList<PaymentInformation> PaymentInformation { get; set; }
    7685    public virtual ContactInformation ContactInformation { get; set; }
     86
     87    public State EntityState { get; set; }
    7788  }
    7889
     
    8596  }
    8697
    87   public class Order {
     98  public class Order : IObjectWithState {
    8899    public long OrderId { get; set; }
    89100    public long UserId { get; set; }
     
    112123      set { BillingPeriodValue = (int)value; }
    113124    }
     125
     126    public State EntityState { get; set; }
    114127  }
    115128
    116   public class OrderLine {
     129  public class OrderLine : IObjectWithState {
    117130    public long OrderLineId { get; set; }
    118131    public long OrderId { get; set; }
     
    123136    public virtual Order Order { get; set; }
    124137    public virtual Product Product { get; set; }
     138
     139    public State EntityState { get; set; }
    125140  }
    126141
     
    129144  }
    130145
    131   public class Invoice {
     146  public class Invoice : IObjectWithState {
    132147    public long InvoiceId { get; set; }
    133148    public long UserId { get; set; }
     
    148163      set { StatusValue = (int)value; }
    149164    }
     165
     166    public State EntityState { get; set; }
    150167  }
    151168
    152   public class InvoiceLine {
     169  public class InvoiceLine : IObjectWithState {
    153170    public long InvoiceLineId { get; set; }
    154171    public long InvoiceId { get; set; }
     
    159176    public virtual Invoice Invoice { get; set; }
    160177    public virtual Product Product { get; set; }
     178
     179    public State EntityState { get; set; }
    161180  }
    162181
    163   public class UsageRecord {
     182  public class UsageRecord : IObjectWithState {
    164183    public long UsageRecordId { get; set; }
    165184    public long UserId { get; set; }
     
    172191    public virtual User User { get; set; }
    173192    public virtual Product Product { get; set; }
     193
     194    public State EntityState { get; set; }
    174195  }
    175196}
Note: See TracChangeset for help on using the changeset viewer.