Discussion Eager Loading on a nullable foreign key is not working

  • Thursday, May 17, 2012 8:10 AM
     
      Has Code

    HI folks

    I am having trouble eager loading a related table that has a nullable foreign key.

    Here is my entities and their relationships:

               Details.Language(not NULLable) ->Language

               Details.Country(NULLable) ->Country

    Language works

    Country doesn't

    I have tried Includes:

                                    Details.Include("Language") /*Language loads */

                                    Details.Include("Country") /*Country doesn't load */

                                   Details.Include("Country").Include("Language") /*Country doesn't load Language does */

    I have tried projection:

     

    Details.Select(cd => new {

    Details = cd,

    language = cd.Language,

    country = cd.Country

    } )


    I haven't tried Load() ('cause I can't get the syntax right)

    var e= CompanyDetails.Select(cd =>  cd);
    e.Language.Load() /* errors*/
    
    

    Has any body got a clue why NULLable relationships won't load?

    regards

    GregJF

All Replies

  • Saturday, May 19, 2012 6:29 AM
     
     
    What's the type of 'Country'? A primitive type or an entity?

    Go go Doraemon!

  • Sunday, May 20, 2012 10:48 PM
     
     
    It is an entity of course