dhl:Using:方法调用完毕立即释放。
方法1:
private TaoXueDBEntities _TaoXueDBEntities = new TaoXueDBEntities();
//销毁TaokeRepository的时候才能销毁_TaoXueDBEntities 建议采用using方法。
public IList<Lesson> GetAllLesson()
{
var query = _TaoXueDBEntities.ExecuteStoreQuery<Lesson>("SELECT * FROM dbo.Lesson");
return query.ToList();
}
--
Using:方法调用完毕立即释放。
public IList<Lesson> GetAllLesson()
{
using (var _TaoXueDBEntities = new TaoXueDBEntities())
{
var query = _TaoXueDBEntities.ExecuteStoreQuery<Lesson>("SELECT * FROM dbo.Lesson");
return query.ToList();
}
}