The key difference between your two implementations is that the second captures a method parameter, while the first does not. The parameter gets stored as a field in a closure, and the presence of that field access is probably causing problems in RefactorThis.GraphDiff.dll
.
Try changing the second implementation as follows:
protected void SetOwnedCollectionMapping<T>(Expression<Func<TDataEntity, ICollection<T>>> mapping)
{
//
// Hack to resolve the `OwnedCollection` extension method.
//
Expression<Func<IUpdateConfiguration<TDataEntity>, object>> template =
_ => _.OwnedCollection(mapping);
var map = Expression.Parameter(
typeof(IUpdateConfiguration<TDataEntity>),
"map");
graphMapping = Expression.Lambda<Func<IUpdateConfiguration<TDataEntity>, object>>(
Expression.Call(
((MethodCallExpression)template.Body).Method,
map,
Expression.Quote(mapping)),
map);
}
The value of graphMapping
should then be identical to that produced by your first implementation.