locked
Lazy Loading - Load a single property from a navigation property? Is that possible? RRS feed

  • Question

  • Hello guys,

        I'm using wpf + ef5 and i'm having a huge problem.

        I'm currently using LazyLoading in all my application. And, in a simple DataGrid with like, 2-3k records the scrolling is impossible...

        It seems to me that the lazyloading is loading the data and it slows the scrolling down. I'm wondering if there's a way of loading only a property from a navigation property to show on the datagrid.

        Example:

    Let's say i have a datagrid that is supposed to show Persons and they're Address information like, zipcode, street, country, localArea name, etc.

    All those address informations are Entities, so, when i'm using lazyloading there's a bunch of navigation properties always loading and requesting data from remote db server (i think thats the problem).

    Solution?: I have tried to ofc disable the lazyloading but it consumes A LOT of memory for 2-3k of records that is not too much at all...

    Question?: From the previous example of Person and Address, i only need to load like the property "description" for each table/entity, so, i'm wondering if it is possible to load only the properties from the navigation properties i need.

    Monday, June 17, 2013 9:27 AM

Answers

All replies

  • You can do this using eager loading or explicit loading. Please refer to this article for more information and code samples: http://msdn.microsoft.com/en-us/data/jj574232.aspx

    • Marked as answer by Jorge_M_P Thursday, June 20, 2013 9:52 AM
    Monday, June 17, 2013 10:39 AM
  • Hi;

    To yor question, "Question?: From the previous example of Person and Address, i only need to load like the property "description" for each table/entity, so, i'm wondering if it is possible to load only the properties from the navigation properties i need.", yes you can do this in the select clause of the query.


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, June 17, 2013 5:12 PM