question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LoadWith makes queries for each entity

See original GitHub issue
class Directory
{
    public long Id { get; set;}
    public string Path { get; set;}
    public IEnumerable<File> Files { get; set;}
}

class File
{
    public long Id { get; set;}
    public long DirectoryId { get; set; }
    public string Name { get; set; }
    public Directory Directory { get; set; }
}

db.Directory.LoadWith(d => d.files)

Fails with exception “Multiple queries are not allowed. Set the ‘LinqToDB.Common.Configuration.Linq.AllowMultipleQuery’ flag to ‘true’ to allow multiple queries.”

If set AllowMultipleQuery to true, it generates query for each directory entry,

May be it could be done with one query?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:24 (17 by maintainers)

github_iconTop GitHub Comments

2reactions
igor-tkachevcommented, May 19, 2015
db.Directory.LoadWith(d => d.Files[0].Properties);
0reactions
MaceWinducommented, Dec 17, 2022

PLease open new issue with query and model

Read more comments on GitHub >

github_iconTop Results From Across the Web

Linq2SQl eager load with multiple DataLoadOptions
Be careful, DataLoadOptions creates some very inefficient queries. – Chad Moran. Mar 13, 2009 at 21:01. Thanks, ...
Read more >
Loading Related Entities - EF6
For example, the queries below will load blogs and all the posts related to ... Entity namespace so make sure you are using...
Read more >
LINQ to SQL Tricks: Building Efficient Queries that Include ...
Using the LoadWith() data option we can hint LINQ to SQL that every time entity X is being requested its child entity Y...
Read more >
Constraints With LoadWith when Loading multiple 1:n ...
Looking at the query sent to the database, you can confirm that there was not ... Example below shows separate database calls made...
Read more >
LINQ to SQL Gotcha #1: Unexpected LoadWith Behaviour
When you want to eager load an entity's associated data you need to set ... this will still generate one query with JOIN...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found