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

  • SEARCH
  • Home
  • 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 4018696
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:00:54+00:00 2026-05-20T10:00:54+00:00

I would think this is very basic stuff, but I’m just not getting it

  • 0

I would think this is very basic stuff, but I’m just not getting it to work.

I try to get a list of objects using lambda expressions like this :

 List<LocalizationGlobalText> list = _entities.LocalizationGlobalTexts.Where(l => l.Language.Id == _currentlanguage).ToList<LocalizationGlobalText>();

The list is fetched, but the foreign key objects are all null.
I also tried using LINQ to entities but this results in the same problem :

        IEnumerable<LocalizationGlobalText> bla = (from lgt in _entities.LocalizationGlobalTexts
                                                   join lg in _entities.LocalizationGlobals on lgt.IdLocalizationGlobal equals lg.Id
                                                   where lgt.IdLanguage == _currentlanguage
                                                   select lgt);
  • 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-20T10:00:54+00:00Added an answer on May 20, 2026 at 10:00 am

    By default, Entity Framework only brings in the collection that you specify, without any foreign objects. If you have lazy loading enabled, accessing the foreign properties will cause them to be lazily initialized. If not, you’ll need to tell entity framework to eagerly load the properties you want with the first batch.

    There are two ways to do this. The first is the “official” way, but I don’t like it because it uses magic strings:

    var list = _entities.LocalizationGlobalTexts.Include("ForeignProp")
                  .Where(l => l.Language.Id == _currentlanguage)
                  .ToList<LocalizationGlobalText>();
    

    (Replace “ForeignProp” with the name of the property you want it to eagerly load)

    The second way is to set up your selector so that it will be forced to pull this extra data in:

    var list = _entities.LocalizationGlobalTexts
                  .Where(l => l.Language.Id == _currentlanguage)
                  .Select(l => new {l, l.ForeignProp})
                  .ToList();
    
    foreach(var item in list)
    {
        Console.WriteLine(item.l.Name + item.ForeignProp.Title);
    }
    

    Since Entity Framework is smart enough to have made the appropriate connections, you could throw on one more selector and avoid using the anonymous type afterward:

    var list = _entities.LocalizationGlobalTexts
                  .Where(l => l.Language.Id == _currentlanguage)
                  .Select(l => new {l, l.ForeignProp})
                  .AsEnumerable() // tells EF to load now. The rest is LINQ to Objects
                  .Select(i => i.l)
                  .ToList();
    
    foreach(var localization in list)
    {
        Console.WriteLine(localization.Name + localization.ForeignProp.Title);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen many tutorials, but they're so confusing, and to do what I
I would like to know how to create a method which takes an ArrayList
I would like to read out the volume of the audio played at the
I'm using this jquery to serialize my form and pass it to a PHP
Suppose I have my Android app's source code packaged this way: src/ my/ app/
All, In Apple's sample code DateCell http://developer.apple.com/library/ios/#samplecode/DateCell/Introduction/Intro.html the ivar pickerView is declared in MyTableViewController.h
I'm working on a solo project, using the aforementioned technologies. The aim is to
Suppose we have buyers and sellers that are trying to find each other in
I frequently need to have a thread wait for the result of another thread.

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.