How to dispose data context after usage
Posted
by Erwin
on Stack Overflow
See other posts from Stack Overflow
or by Erwin
Published on 2010-05-20T05:03:40Z
Indexed on
2010/05/20
5:10 UTC
Read the original article
Hit count: 449
Hi fellow programmer
I have a member class that returned IQueryable from a data context
public static IQueryable<TB_Country> GetCountriesQ()
{
IQueryable<TB_Country> country;
Bn_Master_DataDataContext db = new Bn_Master_DataDataContext();
country = db.TB_Countries
.OrderBy(o => o.CountryName);
return country;
}
As you can see I don't delete the data context after usage. Because if I delete it, the code that call this method cannot use the IQueryable (perhaps because of deferred execution?). How to force immediate execution to this method? So I can dispose the data context..
Thank you :D
© Stack Overflow or respective owner