Skip to content
This repository was archived by the owner on Feb 1, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
handle AsNoTrackingWithIdentityResolution (#352)
  • Loading branch information
MaceWindu authored Oct 13, 2023
commit bfeb866c28f825ae91af8516af9c07f03ec796cb
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ public virtual MappingSchema GetMappingSchema(
MemberHelper.MethodOfGeneric<IIncludableQueryable<object, IEnumerable<object>>>(q => q.ThenInclude<object, object, object>(null!));

static readonly MethodInfo AsNoTrackingMethodInfo = MemberHelper.MethodOfGeneric<IQueryable<object>>(q => q.AsNoTracking());
static readonly MethodInfo AsNoTrackingWithIdentityResolutionMethodInfo = MemberHelper.MethodOfGeneric<IQueryable<object>>(q => q.AsNoTrackingWithIdentityResolution());

static readonly MethodInfo EFProperty = MemberHelper.MethodOfGeneric(() => EF.Property<object>(1, ""));

Expand Down Expand Up @@ -834,7 +835,8 @@ TransformInfo LocalTransform(Expression e)
methodCall.Arguments[0], Expression.NewArrayInit(typeof(Type)));
return new TransformInfo(newMethod, false, true);
}
else if (generic == AsNoTrackingMethodInfo)
else if (generic == AsNoTrackingMethodInfo
|| generic == AsNoTrackingWithIdentityResolutionMethodInfo)
{
isTunnel = true;
tracking = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
namespace LinqToDB.EntityFrameworkCore.BaseTests.Models.ForMapping;

public class WithInheritance
namespace LinqToDB.EntityFrameworkCore.BaseTests.Models.ForMapping
{
public int Id { get; set; }
public string Discriminator { get; set; } = null!;
}
public class WithInheritance
{
public int Id { get; set; }
public string Discriminator { get; set; } = null!;
}

public class WithInheritanceA : WithInheritance
{

}
public class WithInheritanceA : WithInheritance
{

public class WithInheritanceA1 : WithInheritanceA
{

}
}

public class WithInheritanceA2 : WithInheritanceA
{

public class WithInheritanceA1 : WithInheritanceA
{

}

public class WithInheritanceA2 : WithInheritanceA
{

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,13 @@ public void Issue321Test()

var _ = ctx.Patents.AsSqlServer().ToLinqToDB().ToArray();
}

[Test(Description = "https://github.com/linq2db/linq2db.EntityFrameworkCore/issues/345")]
public void AsNoTrackingWithIdentityResolutionHandling()
{
using var ctx = CreateContext();

_ = ctx.Patents.AsNoTrackingWithIdentityResolution().ToLinqToDB().ToArray();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private NorthwindContext CreateContext(bool enableFilter)
if (ctx.Database.EnsureCreated())
{
NorthwindData.Seed(ctx);
}
}
return ctx;
}

Expand Down