나는 여기서 논의 된 방법에 대해 알고 :컴파일 된 LINQ 쿼리 및 DataLoadOptions ... 트위스트!
Solving common problems with Compiled Queries in Linq to Sql for high demand ASP.NET websites
...하지만 난이 얻을으로이 내 상황에 작동하지 않습니다로드 옵션을 설정
는 "결과 후 허용되지 않습니다
가지고 쿼리에서 반환되었습니다. "나는 엔티티와 관리자 코드를 생성하는 Codesmith PLINQO 스크립트를 사용하고, 그리고 관리자 코드는 다음과 같은 :
: 내가 처음과 같이 Searchmanager 클래스에 정적 DataLoadOptions을 삭제 시도public partial class SearchManager
{
#region Query
// A private class for lazy loading static compiled queries.
private static partial class Query
{
internal static readonly Func<MyDataContext,IOrderedQueryable<Search>>
GetAll = CompiledQuery.Compile(
(MyDataContext db) =>
from s in db.Search
orderby s.Name
select s);
}
#endregion
public IQueryable<Search> GetAll()
{
return Query.GetAll(Context);
}
}
public IQueryable<Search> GetAll()
{
Context.LoadOptions = MyOptions;
return Query.GetAll(Context);
}
:
public static readonly DataLoadOptions MyOptions =
(new Func<DataLoadOptions>(() =>
{
var option = new DataLoadOptions();
option.LoadWith<Search>(x => x.Rule);
return option;
}))();
... 다음과 같은 방법 GETALL 컨텍스트에 제공
... 그리고 그게 내가 위에서 지적한 오류를 줬어. 이것은 쿼리가 이미 컴파일되어 있으므로 "추가"DataLoadOptions를 추가 할 수 없기 때문입니까? 그렇다면 어떻게 쿼리를 컴파일하기 전에 DataLoadOptions을 적용 할 수 있습니까?
체크 게시 된 답하고 실제로 오류가 쿼리를 호출하기 전에 발생하면 –