|
14 | 14 | using Microsoft.EntityFrameworkCore.Metadata; |
15 | 15 | using Microsoft.EntityFrameworkCore.Query; |
16 | 16 | using Microsoft.EntityFrameworkCore.Query.Internal; |
| 17 | +using Microsoft.EntityFrameworkCore.Query.ExpressionVisitors; |
17 | 18 | using Microsoft.Extensions.Logging; |
18 | 19 |
|
19 | 20 | using JetBrains.Annotations; |
20 | | -using Microsoft.EntityFrameworkCore.Query.ExpressionVisitors; |
21 | 21 |
|
22 | 22 | namespace LinqToDB.EntityFrameworkCore |
23 | 23 | { |
@@ -388,6 +388,12 @@ public virtual IDbContextOptions GetContextOptions(DbContext context) |
388 | 388 | static readonly MethodInfo AsNoTrackingMethodInfo = |
389 | 389 | MemberHelper.MethodOf<IQueryable<object>>(q => q.AsNoTracking()).GetGenericMethodDefinition(); |
390 | 390 |
|
| 391 | + static readonly MethodInfo EFProperty = |
| 392 | + MemberHelper.MethodOf(() => EF.Property<object>(1, "")).GetGenericMethodDefinition(); |
| 393 | + |
| 394 | + private static readonly MethodInfo |
| 395 | + L2DBProperty = typeof(Sql).GetMethod(nameof(Sql.Property)).GetGenericMethodDefinition(); |
| 396 | + |
391 | 397 | public static Expression Unwrap(Expression ex) |
392 | 398 | { |
393 | 399 | if (ex == null) |
@@ -657,14 +663,14 @@ Expression LocalTransform(Expression e) |
657 | 663 | case ExpressionType.Call: |
658 | 664 | { |
659 | 665 | var methodCall = (MethodCallExpression) e; |
| 666 | + var generic = methodCall.Method.IsGenericMethod ? methodCall.Method.GetGenericMethodDefinition() : methodCall.Method; |
660 | 667 |
|
661 | 668 | if (IsQueryable(methodCall)) |
662 | 669 | { |
663 | 670 | if (methodCall.Method.IsGenericMethod) |
664 | 671 | { |
665 | 672 | var isTunnel = false; |
666 | 673 |
|
667 | | - var generic = methodCall.Method.GetGenericMethodDefinition(); |
668 | 674 | if (generic == IgnoreQueryFiltersMethodInfo) |
669 | 675 | { |
670 | 676 | ignoreQueryFilters = true; |
@@ -705,6 +711,13 @@ Expression LocalTransform(Expression e) |
705 | 711 | } |
706 | 712 | } |
707 | 713 |
|
| 714 | + if (generic == EFProperty) |
| 715 | + { |
| 716 | + var prop = Expression.Call(null, L2DBProperty.MakeGenericMethod(methodCall.Method.GetGenericArguments()[0]), |
| 717 | + methodCall.Arguments[0].Transform(l => LocalTransform(l)), methodCall.Arguments[1]); |
| 718 | + return prop; |
| 719 | + } |
| 720 | + |
708 | 721 | break; |
709 | 722 | } |
710 | 723 | } |
|
0 commit comments