views:

44

answers:

2

I'm using linq to sql. And do something like:

IEnumerable<VarValues> parameters = GetDayParameters();

protected IEnumerable<VarValues> GetDayParameters()
{
    return "some linq query";
}

After that, i'm using LINQ to Objects for "parameters"-variable, in loop, and that queries start to connect to database. Question is, can i force LINQ to SQL, get, all i want from database into parameters variable, and do not connect to database, anymore.

+3  A: 

assign the result of your linq query to var object v and then return v.ToList()

A_Nablsi
yes. that solved the problem!
eba
:) Good luck...
A_Nablsi
+2  A: 

Normally LINQ to SQL is not bound to database once you have received data from database.

like if you see following blog of ScottGu

http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx

You can connect to database get values and then play with your object and pass the values back.

ExampleЖ

DatabaseContext db = new DatabaseContext()

then you can query your database like

var mytable = from a in db.MyTable
              where yournormal_where_statement
              select a;

I hope it will help

zish
so my problem is, it doesnt work, as u tell me
eba