From 54250700b32631fc8f6cb21bd2d016b71666e419 Mon Sep 17 00:00:00 2001 From: Svyatoslav Danyliv Date: Thu, 18 May 2023 19:36:35 +0300 Subject: [PATCH] Excluded a bunch of methods which are evaluated by mistake. (#328) --- .../LinqToDBForEFToolsImplDefault.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs b/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs index db07805..4926ec4 100644 --- a/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs +++ b/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs @@ -544,6 +544,12 @@ public virtual MappingSchema GetMappingSchema( static readonly MethodInfo TagWithMethodInfo = MemberHelper.MethodOfGeneric>(q => q.TagWith(string.Empty)); + static readonly MethodInfo AsSplitQueryMethodInfo = + MemberHelper.MethodOfGeneric>(q => q.AsSplitQuery()); + + static readonly MethodInfo AsSingleQueryMethodInfo = + MemberHelper.MethodOfGeneric>(q => q.AsSingleQuery()); + static readonly MethodInfo ThenIncludeEnumerableMethodInfo = MemberHelper.MethodOfGeneric>>(q => q.ThenInclude(null!)); @@ -878,6 +884,11 @@ TransformInfo LocalTransform(Expression e) break; } + if (generic == AsSplitQueryMethodInfo || generic == AsSingleQueryMethodInfo) + { + return new TransformInfo(methodCall.Arguments[0], false, true); + } + if (typeof(ITable<>).IsSameOrParentOf(methodCall.Type)) { if (generic.Name == "ToLinqToDBTable") @@ -890,8 +901,9 @@ TransformInfo LocalTransform(Expression e) if (typeof(IQueryable<>).IsSameOrParentOf(methodCall.Type) && methodCall.Type.Assembly != typeof(LinqExtensions).Assembly) { - if (null == methodCall.Find(nonEvaluatableParameters, - (c, t) => t.NodeType == ExpressionType.Parameter && c.Contains(t))) + if (dc.MappingSchema.GetAttribute(methodCall.Type, methodCall.Method) == null + && null == methodCall.Find(nonEvaluatableParameters, + (c, t) => t.NodeType == ExpressionType.Parameter && c.Contains(t) || t.NodeType == ExpressionType.Extension)) { // Invoking function to evaluate EF's Subquery located in function