0

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.

1
  • please improve the title of your question. Commented Oct 28, 2010 at 8:03

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

Comments

2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.