3
영어로 죄송합니다. .NET 3.5에서 LINQ to SQL 쿼리를 사용하고 SearchDeviceExpression 메서드에서 DeviceExpression 메서드를 다시 사용하려고합니다. 런타임에서 그람다 식의 재사용
public static Expression<Func<DEVICE_TYPE, bool>> SearchDeviceExpression2(string s)
{
return o => DEVICE_TYPE.DeviceExpression().Compile()(o) == s;
}
같은 뭔가가 나는 예외 Method 'System.Object DynamicInvoke(System.Object[])' has no supported translation to SQL
를 얻을. 그 방법에 대한 번역이 없지만 해결 방법이있을 수 있다는 것은 사실입니다.
내 수업.
[Table(Name = "DEVICE_TYPE_LOCAL")]
public class DEVICE_TYPE
{
[Column]
public string DEV_CODE
{
get;
set;
}
[Column]
public string DEVICE_NAME
{
get;
set;
}
[Column]
public string DEVICE_MARK
{
get;
set;
}
public static Expression<Func<DEVICE_TYPE, string>> DeviceExpression()
{
return o => "(" + o.DEV_CODE + ") " + o.DEVICE_NAME + " " + o.DEVICE_MARK;
}
public static Expression<Func<DEVICE_TYPE, bool>> SearchDeviceExpression(string s)
{
return o => "(" + o.DEV_CODE + ") " + o.DEVICE_NAME + " " + o.DEVICE_MARK == s;
}
}
당신이 실행할 수있는 방법이다. context.GetTable() .AsQueryable(). (o => o.SearchDeviceExpression().) 컴파일(). 호출 (searchStr))'예외를 throw합니다. '메서드 "System.Linq.Expressions.Expression'1 [System. Func'2 [System.String, System.Boolean]] SearchDeviceExpression() "SQL에 지원되는 변환이 없습니다." –
Segment