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 3663796
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:34:17+00:00 2026-05-19T01:34:17+00:00

When I do a lunq query on an EF model, does it not get

  • 0

When I do a lunq query on an EF model, does it not get child entities we well? I have a Transaction table, which has link to a Payee, and a transaction type entity. Also, each transaction has a list of transaction lines…

But the code bellow – all the child objects seen to be NULL, yet the data in the actual entity (Date) seems OK. But in the line: t.account.account_id; …. ‘account’ is NULL.

 public static List<AccountTransactionDto> GetTransaction()
    {
        var trans = (from t in Db.account_transaction
                     select t).ToList();
        List<AccountTransactionDto> al = new List<AccountTransactionDto>();

        foreach(var t in trans)
        {
            AccountTransactionDto a = new AccountTransactionDto();
            a.AccountId = t.account.account_id;
            a.AccountTransactionId  = t.account_transaction_id;
            a.PayeeId = t.payee.payee_id;
            a.TransactionDate = t.transaction_date;
            a.TransactionTypeId = t.z_transaction_type.transaction_type_id;

            foreach(var tl in t.account_transaction_line)
            {
                AccountTransactionLineDto l = new AccountTransactionLineDto();
                l.AccountTransactionLineId = tl.account_transaction_line_id;
                l.Amount = tl.amount;
                l.BudgetId = tl.budget.budget_id;
                l.CostCenterId = tl.cost_centre.cost_centre_id;
                l.SubCategoryId = tl.sub_category.sub_category_id;
                a.AccountTransactionLine.Add(l);
            }

            al.Add(a);
        }
        return al;
    }
  • 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-19T01:34:17+00:00Added an answer on May 19, 2026 at 1:34 am

    You have two options. You can enable the Lazy Loading via:

    Db.ContextOptions.LazyLoadingEnabled = true;
    

    Or if you change the query line to this (exact syntax may not be correct for Include):

    var trans = (from t in Db.account_transaction
                 select t).Include("account_transaction.account_transaction_line");
    

    Then it should pull back the child records with the parent record in a single result set. But this has performance penalties if there is a great amount of data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of files (stored in db which I get using Linq),
How do I get an child element of an xElement in the example below:
I have a LINQ query that starts with var LinqQuery. But I want to
I have this LINQ query and I need to make a second Join to
For some reason in my where it says that firstname does not exist in
I have this LINQ query (sorry it;s a long one) that query sets from
I'm new to infragistics. I have a database and a datalayer with entity framework
I have a database schema (MySql) exposed as a data/OData service that is queried
I have a Foreach loop and every iteration puts the record into a system.
I am trying to GROUP the CRM records that have the same Owner name

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.