我在学习用三层开发(当然我是菜鸟)、底层ORM Linq2Sql看Bll 的代码 public class Area { public EntitiesDataContext Entities = new EntitiesDataContext(); /// <summary> /// 还回所有行 /// </summary> /// <returns></returns> public IQueryable<TbArea> GetAll() { return Entities.TbArea; } }操作public class AreaController : Controller{ public Area Area = new Area(); public ActionResult Display(string id) { var area = Area.GetEntityById(id) ?? new TbArea().Initialize(); return View(area); }}每次代码运行到 public Area Area = new Area();它都会执行一次public EntitiesDataContext Entities = new EntitiesDataContext();感觉很费资源。请问我要怎么作优化?
- 4 回答
- 0 关注
- 195 浏览
添加回答
举报
0/150
提交
取消