Skip to content

Commit ea088de

Browse files
authored
Update DbContextExtensions.cs
1 parent 424def4 commit ea088de

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed
Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* This code is provided as is with no warranty. If you find a bug please report it on github.
33
* If you would like to use the code please leave this comment at the top of the page
44
* License MIT (c) Brent McKendrick 2012
@@ -12,25 +12,27 @@
1212

1313
namespace RefactorThis.GraphDiff
1414
{
15-
public static class DbContextExtensions
16-
{
15+
public static class DbContextExtensions
16+
{
1717
/// <summary>
18-
/// Merges a graph of entities with the data store.
18+
/// Merges a graph of entities with the data store.
1919
/// </summary>
2020
/// <typeparam name="T">The type of the root entity</typeparam>
2121
/// <param name="context">The database context to attach / detach.</param>
2222
/// <param name="entity">The root entity.</param>
2323
/// <param name="mapping">The mapping configuration to define the bounds of the graph</param>
24-
/// <param name="allowDelete">NEED TEXTE!!!!</param>
24+
/// <param name="allowDelete">NEED TEXTE!!!!</param>
2525
/// <returns>The attached entity graph</returns>
26-
public static T UpdateGraph<T>(this DbContext context, T entity, Expression<Func<IUpdateConfiguration<T>, object>> mapping = null, bool allowDelete = true) where T : class, new()
27-
{
28-
var root = mapping == null ? new GraphNode() : new ConfigurationVisitor<T>().GetNodes(mapping);
29-
root.AllowDelete = allowDelete;
30-
var graphDiffer = new GraphDiffer<T>(root);
31-
return graphDiffer.Merge(context, entity);
32-
}
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+
{
30+
var root = mapping == null ? new GraphNode() : new ConfigurationVisitor<T>().GetNodes(mapping);
31+
root.AllowDelete = allowDelete;
32+
var graphDiffer = new GraphDiffer<T>(root);
33+
return graphDiffer.Merge(context, entity);
34+
}
3335

3436
// TODO add IEnumerable<T> entities
35-
}
37+
}
3638
}

0 commit comments

Comments
 (0)