Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 279621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:02:53+00:00 2026-05-12T05:02:53+00:00

DBML I have the following entities in my dbml: (made up for an example)

  • 0

DBML

I have the following entities in my dbml: (made up for an example)

Book <- Media -> AuthorsForMedia <- Author

The arrows are the relationships in my dbml.

A book is a type of media, and an instance of a book has a media property with the values common to all media in it. AuthorsForMedia is an intersecting table with an AuthorId, a MediaId, and an AuthorsForMediaId.

Query

My get query in my repository is:

public Book Get(int id)
{
    var query = from b in db.Books
                where b.BookId == id
                select b;

    return query.Single();
}

The resulting object has the book properties set, and media property with all of its values set.

When I look at AuthorsForMedia in the Watch dialog while debugging, the following values are set:

Count = 0 
HasLoadedOrAssignedValues = false
IsDeferred = false

Question 1

Why can’t the values for AuthorsForMedia (and then its corresponding Author property) be evaluated with lazy loading?

Things I Tried

After reading this question:

  • LINQ to SQL eager loading with conditions

I tried the DataLoadOptions with LoadWith/AssoicateWith and it didn’t work. I ended up with errors like

  • Unable to create instance of class Foo Error: System.NotSupportedException: Subquery is not supported on Media of type Book
  • … System.InvalidOperationException: The expression specified must be of the form p.A, where p is the parameter and A is a property or field member
  • Or the value just wasn’t there

I can supply code snippets for all of this if it helps, but I think its a conceptual issue not a syntatic one.

Summary

How should I be retrieving these values, should it be a left join, or something else I haven’t found so far?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T05:02:53+00:00Added an answer on May 12, 2026 at 5:02 am

    This is how the LoadWith should look.

    DataLoadOptions dlOptions = new DataLoadOptions();
    dlOptions.LoadWith<Books>(book => book.AuthorsForMedia);
    db.LoadOptions = dlOptions;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Do you have one gigantic linq to sql DBML or Linq to entities .EDMX
We have a design with 150+ tables and in the .dbml layout has lines
I have the following 3 classes in my dbml file: public class Player {
I have dbml with single table users i want add partial class for User
I have a .dbml file which of course contains the auto-generated classes based on
I have a dbml to which I have added more then 15 tables from
I have several Stored Procedures that when added to my dbml, it seems that
I have a case where I have a linq2sql dbml with 2 table in
So I've created a dbml in my project, which has three tables: Elements, ElementImages
I'm have .dbml Linq to SQL class named DExamination.dbml [global::System.Data.Linq.Mapping.TableAttribute(Name=dbo.Examination)] public partial class Examination

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.