![](/img/trans.png)
[英]Does too many projects in a solution slow down Visual Studio performance?
[英]Does too many Linq DataContexts slow down loading time?
我的数据访问层使用如下语法:
public static List<MyTableInstance> dataBaseAccessMethod(int someValue)
{
using(myCustomDataContext db = new myCustomDataContext())
{
return (from x in db.MyTable where x.Param = someValue select x).ToList();
}
}
问题是:如果一个页面正在访问上述20种数据访问方法,从而创建20个myCustomDataContext对象,这是由于为每个myCustomDataContext引入了往返行程,从而减少了我页面的加载时间。 即)从理论上讲,减少每个页面的dataContext对象数量是否会对网页的加载时间产生重大影响?
大部分时间都是通过往返数据库消耗的。 您需要组合查询以减少往返次数。 这与dataContext对象的数量无关,即使使用单个dataContext对象,您也可以对数据库进行很多轮询。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.