C# 太多的Linq数据上下文是否会减慢加载时间?

C# 太多的Linq数据上下文是否会减慢加载时间?,c#,sql,performance,linq,azure,C#,Sql,Performance,Linq,Azure,我的数据访问层使用如下语法: 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();

我的数据访问层使用如下语法:

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();
    }
}
publicstaticlist数据库访问方法(intsomevalue)
{
使用(myCustomDataContext db=new myCustomDataContext())
{
返回(从db.MyTable中的x开始,其中x.Param=someValue选择x);
}
}

问题是:如果一个页面正在访问20个数据访问方法(如上面的方法),并因此创建20个myCustomDataContext对象,那么这是否会减少页面的加载时间,因为每个myCustomDataContext都引入了一个往返过程。i、 e)从理论上讲,减少每个页面的dataContext对象的数量会对网页的加载时间产生任何重大影响吗?

大部分时间是通过往返数据库来消耗的。您需要合并查询以减少往返次数。这与dataContext对象的数量无关,即使使用单个dataContext对象,您也可以对数据库执行大量的循环操作