1
T4テンプレートの生成を行わずにEF 4でPOCOオブジェクトを使用しています。コンパイルされたクエリのみスカラーパラメータが許されます!
私は、次のコンパイルされたクエリを作成し、パラメータの1つとして、このクラスに渡ししようとすると、それは私にランタイムエラーを与え、この
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;
}
}
}
のようなものをすべてObjectSetsをカプセル化するのDataContextクラスを持っています私はそれが動作します。このようなクエリを変更する場合にのみ、スカラパラメータが
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()
);
許可されていると言って、しかし、私は深く、私は、私がコンパイルされたクエリから見ることがパフォーマンスの向上をすることができます見ておりませんので、そのは、毎回コンパイルされている疑いがあります誰かが何をしているかを指摘する遣り取り?
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
);