Тип класса будет определен во время выполнения и сохранен в переменной Type следующим образом:< /p>
Код: Выделить всё
Type ModelClassType;//type of the class is assigned at runtime to this variable
Код: Выделить всё
var propertyName = "WfmTaskID";
var methodInfo = typeof(List).GetMethod("Contains", new Type[] { typeof(Guid?) });
var parameter = Expression.Parameter(ModelClassType);//ModelClassType is a Type variable and is set at runtime dynamically
var member = Expression.Property(parameter, propertyName);
var constant = Expression.Constant(AwaitingTasksIDs);
Expression Body = Expression.Call(Expression.Constant(AwaitingTasksIDs), methodInfo, member);
var finalExpression = Expression.Lambda(Body, parameter);
Код: Выделить всё
var finalExpression = Expression.Lambda(Body, parameter);
Код: Выделить всё
ParameterExpression of type 'Kar.Model.Infrastructure.ProjectType' cannot be used for delegate parameter of type 'System.Object
Подробнее здесь: https://stackoverflow.com/questions/791 ... namic-type
Мобильная версия