Optimize BuildContainsExpression method performance
Converted the result of the Select() operation to a list, within the BuildContainsExpression method. This prevents multiple enumerations of the 'entities' variable, improving the performance of the method by reducing the number of iterations.
This commit is contained in:
parent
e64a2eaa17
commit
decb5d898c
|
|
@ -19,7 +19,7 @@ public static class ExpressionExtensions
|
|||
public static Expression<Func<TEntity, bool>> BuildContainsExpression<TEntity>(this Expression<Func<TEntity, string>> keySelector, IEnumerable<TEntity> entities) where TEntity : class
|
||||
{
|
||||
var compiledKeySelector = keySelector.Compile();
|
||||
var list = entities.Select(compiledKeySelector);
|
||||
var list = entities.Select(compiledKeySelector).ToList();
|
||||
var property = keySelector.GetProperty()!;
|
||||
var param = Expression.Parameter(typeof(TEntity));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue