Few queries in one query

2 posts, 0 answers
  1. Zbigniew Kozłowski
    Zbigniew Kozłowski avatar
    60 posts
    Member since:
    Apr 2010

    Posted 07 Oct 2010 Link to this post

    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.
  2. Petko_I
    Petko_I avatar
    184 posts

    Posted 12 Oct 2010 Link to this post

    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.

    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
  3. DevCraft banner
Back to Top