, , castCondition Expression<Func<CastInfo, bool>> ( PredicateBuilder).
, n.CastInfo.Any(castCondition) (, CastInfo - , Enumerable.Any, Func<CastInfo, bool>, Expression<Func<CastInfo, bool>>). ?
, #. PredicateBuilder.New<T> ExpressionStarter<T>, , Expression, , Expression<Func<T, bool>> Func<CastInfo, bool>. Enumerable/Queryable lambda func/expression. , , , - complier - n.CastInfo.Any((Func<CastInfo, bool>)castCondition), , , .
LinqKit AsExpandable , "" Invoke, "" . , , Expression<Func<CastInfo, bool>>, :
_context.Name.AsExpandable().Where(n => n.CastInfo.Any(c => castCondition.Invoke(c)));
, . Expression<Func<T, bool> :
Expression<Func<CastInfo, bool>> castPredicate = castCondition;
_context.Name.AsExpandable().Where(n => n.CastInfo.Any(c => castPredicate.Invoke(c)));
_context.Name.AsExpandable().Where(n => n.CastInfo.Any(castPredicate.Compile()));
, , :
using System;
using System.Linq.Expressions;
namespace LinqKit
{
public static class Extensions
{
public static Expression<Func<T, bool>> ToExpression<T>(this ExpressionStarter<T> expr) => expr;
}
}
var castPredicate = castCondition.ToExpression();
- , .. :
_context.Name.AsExpandable().Where(n => n.CastInfo.Any(c => castCondition.ToExpression().Invoke(c)));