|
1 | | -/* |
| 1 | +/* |
2 | 2 | * This code is provided as is with no warranty. If you find a bug please report it on github. |
3 | 3 | * If you would like to use the code please leave this comment at the top of the page |
4 | 4 | * License MIT (c) Brent McKendrick 2012 |
|
12 | 12 |
|
13 | 13 | namespace RefactorThis.GraphDiff |
14 | 14 | { |
15 | | - public static class DbContextExtensions |
16 | | - { |
| 15 | + public static class DbContextExtensions |
| 16 | + { |
17 | 17 | /// <summary> |
18 | | - /// Merges a graph of entities with the data store. |
| 18 | + /// Merges a graph of entities with the data store. |
19 | 19 | /// </summary> |
20 | 20 | /// <typeparam name="T">The type of the root entity</typeparam> |
21 | 21 | /// <param name="context">The database context to attach / detach.</param> |
22 | 22 | /// <param name="entity">The root entity.</param> |
23 | 23 | /// <param name="mapping">The mapping configuration to define the bounds of the graph</param> |
| 24 | + /// <param name="allowDelete">NEED TEXTE!!!!</param> |
24 | 25 | /// <returns>The attached entity graph</returns> |
25 | | - public static T UpdateGraph<T>(this DbContext context, T entity, Expression<Func<IUpdateConfiguration<T>, object>> mapping = null) where T : class, new() |
26 | | - { |
| 26 | + public static T UpdateGraph<T>(this DbContext context, T entity, |
| 27 | + Expression<Func<IUpdateConfiguration<T>, object>> mapping = null, bool allowDelete = true) |
| 28 | + where T : class, new() |
| 29 | + { |
27 | 30 | var root = mapping == null ? new GraphNode() : new ConfigurationVisitor<T>().GetNodes(mapping); |
| 31 | + root.AllowDelete = allowDelete; |
28 | 32 | var graphDiffer = new GraphDiffer<T>(root); |
29 | 33 | return graphDiffer.Merge(context, entity); |
30 | | - } |
| 34 | + } |
31 | 35 |
|
32 | 36 | // TODO add IEnumerable<T> entities |
33 | | - } |
| 37 | + } |
34 | 38 | } |
0 commit comments