1
T4 템플릿 생성없이 EF 4에서 POCO 개체를 사용하고 있습니다.컴파일 된 쿼리 만 스칼라 매개 변수가 허용됩니다!
는 내가의 DataContext의 모든 ObjectSets를 캡슐화 클래스,이 같은 내가 다음 컴파일 된 쿼리를 작성하고 매개 변수의 하나로서이 클래스에서 통과 할 때
public sealed class DataContext :IDisposable
{
public IObjectSet GetObjectSet() where T : MyBase
{
object objectSet = null;
this.objectSets.TryGetValue(typeof(T), out objectSet);
if (objectSet == null)
{
objectSet = this.context.CreateObjectSet();
this.objectSets.Add(typeof(T), objectSet);
}
return (IObjectSet)objectSet;
}
public ObjectContext ObjectContext
{
get
{
return this.context;
}
}
}
, 그것은 나에게 런타임 오류를 제공을 할 수있는, 내가 그것을 작동과 같이 쿼리를 수정하면 말 스칼라 매개 변수
static readonly Func<ObjectContext , DataContext, string, int?> getOperationByOrchestrationName
= CompiledQuery.Compile(
(ObjectContext ctx, DataContext container, string name) =>
(from or in container.GetObjectSet<MyOrClass>()
join op in container.GetObjectSet<MyOpClass>()
on or.Id equals op.Id
where op.Name == name
select op.Id).FirstOrDefault()
);
을 사용할 수 있습니다,하지만 난 깊이 내가 컴파일 된 쿼리에서 볼 것이 성능 향상을보고 있지 않다 이후는, 때마다 컴파일되는 의심 누군가는 무슨 일이 일어나는지 지적한다. 에 ing?
static readonly Func, IObjectSet, string, IQueryable>
getOperationByOrchestrationName
= CompiledQuery.Compile(
(ObjectContext ctx, IObjectSet ors, IObjectSet ops,string operationName) =>
from or in ors
join op in ops
on or.Id equals op.Id
where op.Name == name
select op.Id
);