The connection is made when you really start the enumeration and when you click SubmitChanges (if there are changes that need to be made). I'm not sure that in the above code, only one connection is opened and used, but I know that in the two places that I mentioned, you will refer to the connection.
LinqPad dimecasts. Linq 2 Sql
, - (getTenSomethingElse (s, s, s)) db, ,
partial class MyDataContext
{
public System.Linq.IQueryable<SomethingElse> getSomethingElse(string searchTerm, string searchValue, string orderBy)
{
var items =
from s in
this.Somethings
select new SomethingElse(s);
return items.Where(searchTerm, searchValue).OrderBy(orderBy);
}
public System.Linq.IQueryable<SomethingElse> getTenSomethingElse(string searchTerm, string searchValue, string orderBy)
{
var items =
from s in
this.getSomethingElse(searchTerm, searchValue, orderBy)
select s;
return items.Take(10);
}
}
IDK , , , , .
, , "Where (s, s)" ScottGu awesome blog