running a compiled Query more than one time results in a "object disposed" Exception.
Code: Select all
public static Func> GetPerson =
CompiledQuery.Compile(
(DataContext1.DataContext1 ctx, int personId) =>
(from obj in ctx.Persons where obj.Personid == personId select obj)
);
for (int i = 0; i person = GetPerson(dataContext1, 1);
dataContext1.Dispose();
}
It seems, that the compiled Query still uses the old dataContext or is there a trick to run such a Query with a new dataContext?