... PreprocessQuery()
LightSwitch
메서드의 쿼리를 디자인하는 데 문제가 있습니다. 모든대리자를 사용하여 LINQ를 사용하는 LightSwitch 사용자 지정 쿼리가 작동하지 않습니다.
첫째, 나는 어떤 작품, 간단한 방법으로 당신을 말할 :
partial void NeedHelp_PreprocessQuery(bool Admin, ref IQueryable<Device> query)
{
// Some code...
query = query.Where<Device>(d => d.IsAvailable());
}
쿼리는 컴파일 오류를 표시하고 무엇을해야하지 않습니다. 나는이 방법으로 논리를 넣어 쿼리에서의 대리자를 사용하려고하면
지금, 하나 더 컴파일 오류가 없다,하지만 난 예외를 얻을. 여기에 코드입니다 :
private bool Logic(Device TheDevice, bool Admin)
{
return Admin ? true : TheDevice.IsAvailable();
}
partial void NeedHelp_PreprocessQuery(bool Admin, ref IQueryable<Device> query)
{
// Some code...
Func<Device, bool, bool> LogicDelegate = new Func<Device, bool, bool>(this.Logic);
query = query.Where<Device>(d => LogicDelegate(d, Admin));
}
예외가 독일어, 나는 필수 번역하려고 :
The expression is not supported. Expression:
Invoke(value(LightSwitchApplication.ApplicationDataService+<>c__DisplayClass4).LogicDelegate, d, value(LightSwitchApplication.ApplicationDataService+<>c__DisplayClass4).Admin)
Message of inner exception:
The type "ApplicationData.Implementation.Device" cannot be used for a parameter of type "LightSwitchApplication.Device".
난 단지 Device
을 사용하고 있기 때문에, 나는 ApplicationData.Implementation.Device
과 LightSwitchApplication.Device
사이에 혼란을 이해하지 않는다! 내가 도대체 뭘 잘못하고있는 겁니까? LightSwitch에서 이런 종류의 호출을 간단히 처리 할 수 없습니까?
답변 해 주셔서 감사합니다. 해결 방법을 사용하여이 문제를 해결했습니다. 여기서 테이블에 날짜 틱이 긴 int로 저장되는 새 필드를 추가했습니다. 이것은 원래 DateTime 필드와 병행하여 관리됩니다. 좋지는 않지만 잘 작동합니다. – Satria