none
Simple LINQ Lazy Loading Question RRS feed

  • Question

  • Can I just check something please - need to sanity check what I think is correct.  If I have some LINQ entity relationships that I create in code thus:-
    private EntityRef<Object1> _objectLink;
    [Association(Name = "Main_Object1", Storage = "_objectLink", ThisKey = "ColumnName", OtherKey = "ColumnName")]
    public Object1 ObjectLink { get { return _objectLink.Entity; } }
    
    private EntitySet<Object2> _objectList = new EntitySet<Object2>();
    [Association(Name = "Main_Object2List", Storage = "_objectList", ThisKey = "OtherColumnName", OtherKey = "OtherColumnName")]
    public IList<Object2> { get { return _objectList.ToList(); } }
    these would lazy load, by default - correct?

    And if the first link was changed to

    private EntityRef<Object1> _objectLink;
    [Association(Name = "Main_Object1", Storage = "_objectLink", ThisKey = "ColumnName", OtherKey = "ColumnName")]
    private Object1 ObjectLink { get { return _objectLink.Entity; } }
    public Object1 GetObjectLink() { return ObjectLink; }
    this would also lazy load and defer loading until GetObjectLink() was called, yes?

    Cheers

    MH 

    Tuesday, March 16, 2010 9:44 AM

All replies

  • Hello,

    Yes, I think so.  However, the question should be for LINQ to SQL instead of for LINQ to Entities, right? 

    I will move this thread to LINQ to SQL forum. 

    Have a nice day!


    Best Regards,
    Lingzhi Sun


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, March 22, 2010 2:45 PM
    Moderator
  • Thanks - sorry for the wrong post - I was directed to post it here by an MS person on another forum.  I've reopened it to see if I get any further responses.
    Wednesday, March 24, 2010 8:31 AM