Free cookie consent management tool by TermsFeed Policy Generator

source: branches/1888_OaaS/HeuristicLab.Services.Optimization.Billing/Utils/DbContextUtil.cs @ 18242

Last change on this file since 18242 was 9645, checked in by spimming, 12 years ago

#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 size: 491 bytes
Line 
1using System.Data.Entity;
2using HeuristicLab.Services.Optimization.Billing.Interfaces;
3
4namespace HeuristicLab.Services.Optimization.Billing.Utils {
5  public static class DbContextUtil {
6    public static void ApplyStateChanges(this DbContext context) {
7      foreach (var entry in context.ChangeTracker.Entries<IObjectWithState>()) {
8        IObjectWithState stateInfo = entry.Entity;
9        entry.State = StateUtil.ConvertState(stateInfo.EntityState);
10      }
11    }
12  }
13}
Note: See TracBrowser for help on using the repository browser.