Skip to content
This repository was archived by the owner on Feb 1, 2025. It is now read-only.

Commit 5425070

Browse files
sdanylivMaceWindu
authored andcommitted
Excluded a bunch of methods which are evaluated by mistake. (#328)
1 parent 9831572 commit 5425070

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,12 @@ public virtual MappingSchema GetMappingSchema(
544544
static readonly MethodInfo TagWithMethodInfo =
545545
MemberHelper.MethodOfGeneric<IQueryable<object>>(q => q.TagWith(string.Empty));
546546

547+
static readonly MethodInfo AsSplitQueryMethodInfo =
548+
MemberHelper.MethodOfGeneric<IQueryable<object>>(q => q.AsSplitQuery());
549+
550+
static readonly MethodInfo AsSingleQueryMethodInfo =
551+
MemberHelper.MethodOfGeneric<IQueryable<object>>(q => q.AsSingleQuery());
552+
547553
static readonly MethodInfo ThenIncludeEnumerableMethodInfo =
548554
MemberHelper.MethodOfGeneric<IIncludableQueryable<object, IEnumerable<object>>>(q => q.ThenInclude<object, object, object>(null!));
549555

@@ -878,6 +884,11 @@ TransformInfo LocalTransform(Expression e)
878884
break;
879885
}
880886

887+
if (generic == AsSplitQueryMethodInfo || generic == AsSingleQueryMethodInfo)
888+
{
889+
return new TransformInfo(methodCall.Arguments[0], false, true);
890+
}
891+
881892
if (typeof(ITable<>).IsSameOrParentOf(methodCall.Type))
882893
{
883894
if (generic.Name == "ToLinqToDBTable")
@@ -890,8 +901,9 @@ TransformInfo LocalTransform(Expression e)
890901

891902
if (typeof(IQueryable<>).IsSameOrParentOf(methodCall.Type) && methodCall.Type.Assembly != typeof(LinqExtensions).Assembly)
892903
{
893-
if (null == methodCall.Find(nonEvaluatableParameters,
894-
(c, t) => t.NodeType == ExpressionType.Parameter && c.Contains(t)))
904+
if (dc.MappingSchema.GetAttribute<ExpressionMethodAttribute>(methodCall.Type, methodCall.Method) == null
905+
&& null == methodCall.Find(nonEvaluatableParameters,
906+
(c, t) => t.NodeType == ExpressionType.Parameter && c.Contains(t) || t.NodeType == ExpressionType.Extension))
895907
{
896908
// Invoking function to evaluate EF's Subquery located in function
897909

0 commit comments

Comments
 (0)