This is a migrated thread and some comments may be shown as answers.

Few queries in one query

1 Answer 64 Views
LINQ (LINQ specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Zbigniew Kozłowski
Top achievements
Rank 1
Zbigniew Kozłowski asked on 07 Oct 2010, 08:50 AM
Hi,
is there a way to make few queries in one query? Because sometimes i need to get few things that are not linked in any way, and i dont want to make few seperates queries, cos its make everytime new conections and sometimes its much slower (like poor wifi or internet conection, where latency is very big). So its faster to get back one big packet than 10 small ones. For example in Normal mysql connection and select i could make few queries and than read each query from reader. And i dont know if there is such possibility in LINQ.

1 Answer, 1 is accepted

Sort by
0
Petko_I
Telerik team
answered on 12 Oct 2010, 04:21 PM
Hi Zbigniew Kozłowski,

I do not think you should worry about connection latency and LINQ. This is a major issue which should be addressed by any ORM tool you use. Connection pooling is utilized behind the scenes, so in general you should not worry about this. If you want to retrieve related data together you can benefit from the fetch optimization API we have introduced. With LINQ many of the queries you build are not propagated to the server until you invoke one of the methods that forces execution – ToList(), FirstOrDefault(), Count(), etc. Bear in mind that in order to execute a query on the database server you should have an active context which manipulates the collections of persistent objects. So, if you have an active context whose life spans several queries, you can defer their execution by not invoking eager-loading methods and execute all the queries at the same time.

Greetings,
Petko_I
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
LINQ (LINQ specific questions)
Asked by
Zbigniew Kozłowski
Top achievements
Rank 1
Answers by
Petko_I
Telerik team
Share this question
or