Last change
on this file since 10120 was
9645,
checked in by spimming, 11 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 | |
---|
1 | using System.Data.Entity;
|
---|
2 | using HeuristicLab.Services.Optimization.Billing.Interfaces;
|
---|
3 |
|
---|
4 | namespace 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.