ここで DataConvert.ToThema() を使用してテーブル オブジェクトをカスタム ビジネス オブジェクトに変換するように、コンパイル済みのクエリに関数を含めると、裏で何が起こりますか。
public static class Queries
{
public static Func<MyDataContext, string, Thema> GetThemaByTitle
{
get
{
var func = CompiledQuery.Compile(
(MyDataContext db, string title) =>
(from th in elan.tbl_Thema
where th.Titel == title
select DataConvert.ToThema(th)).Single()
);
return func;
}
}
}
public static class DataConvert
{
public static Thema ToThema(tbl_Thema tblThema)
{
Thema thema = new Thema();
thema.ID = tblThema.ThemaID;
thema.Titel = tblThema.Titel;
// and some other stuff
return thema;
}
}
そしてそれをこのように呼びます
Thema th = Queries.GetThemaByTitle.Invoke(db, "someTitle");
どうやら関数はSQLなどに変換されていないようですが(どうすればよいでしょうか)、VS2010でブレークポイントを設定しても保持されません。
問題なく動作しますが、方法や理由がわかりません。そこでは正確に何が起こりますか?