public class EcImageWrapper
{
//etc...
public IQueryable<EcFieldWrapper> ListOfFields
{
get
{
//logic here
return this.listOfFields.AsQueryable();
}
}
public EcFieldWrapper FindBy(Expression<Func<EcFieldWrapper, int, bool>> predicate)
{
return this.ListOfFields.Where(predicate).SingleOrDefault();
}
public EcFieldWrapper FindByName(string fieldName)
{
return this.FindBy(x => x.Name.ToUpper() == fieldName.ToUpper());
//error here, wanting 3 arguments
//which makes sense as the above Expression has 3
//but i don't know how to get around this
}
出于某种原因,Expression> 要求我使用 3 个参数,过去我只对有问题的实例使用了 2 个。但是,现在我想通过这个实例中的集合进行查找。
我收到以下错误:
Delegate 'System.Func<MSDORCaptureUE.Wrappers.EcFieldWrapper,int,bool>' does not take 1 arguments
The best overloaded method match for 'CaptureUE.Wrappers.EcImageWrapper.FindBy(System.Linq.Expressions.Expression<System.Func<CaptureUE.Wrappers.EcFieldWrapper,int,bool>>)' has some invalid arguments
Argument 1: cannot convert from 'string' to 'System.Linq.Expressions.Expression<System.Func<CaptureUE.Wrappers.EcFieldWrapper,int,bool>>'
期望的结果:能够在类 EcImageWrapper 的实例中使用返回类型为 EcFieldWrapper 的谓词和 EcFieldWrapper 的谓词类型
为什么需要3?为什么是int?