From 5b8d3b0d1f776a927b975a8059d27c7d68dd945f Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Fri, 22 Feb 2019 11:35:42 +0300 Subject: [PATCH] Fixed #838: Potential memory leak because of ef core query cache --- .../Volo/Abp/Domain/Entities/EntityHelper.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs index 69a4d9ddaa..b6558f34d1 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs @@ -75,11 +75,10 @@ namespace Volo.Abp.Domain.Entities where TEntity : IEntity { var lambdaParam = Expression.Parameter(typeof(TEntity)); - var lambdaBody = Expression.Equal( - Expression.PropertyOrField(lambdaParam, nameof(Entity.Id)), - Expression.Constant(id, typeof(TKey)) - ); - + var leftExpression = Expression.PropertyOrField(lambdaParam, "Id"); + Expression> closure = () => id; + var rightExpression = Expression.Convert(closure.Body, leftExpression.Type); + var lambdaBody = Expression.Equal(leftExpression, rightExpression); return Expression.Lambda>(lambdaBody, lambdaParam); } }