We are using Self-Tracking Entities over a WCF service. Entities get ret开发者_如何转开发urned to the client without their Navigational properties loaded.
Is it a better idea to send over all navigational properties at once, or to lazy load them as needed? If lazy loaded, is it a good idea to load them asynchronously? All the WCF service calls I have so far use the await/async keywords.
I have some concern about loading them all at once because some objects have a lot of navigational properties which are not always used. For example, the Consumer entity currently has about 20 and is expected to get more. Some examples include Addresses, Phones, Documents, and Notes. Users can setup their own work area so someone working with documents might always need the Documents property when a Consumer loads, while most others would not.
It really depends on the way how you use entities. The most costly will be round trip to the service so if you have navigation properties which are used in most scenarios you can eager load them but for navigation properties used only occasionally you can use "lazy loading". The real answer to your question can be provided only by some significant analysis of your application and performance tests.
What I'm afraid of little bit is the way how you can update such model. Once you load all related entities and make one object graph from them can you send just part of the graph back to the service? I expect you can't.
Edit:
I read your other question with "dynamic UI". So once the user starts the application you probably know what UI widgets should be displayed. You can expose some initial method which will pass description of all navigation properties required by currently opened widgets and load other properties when new widget is opened. Simply adding widget will take some time to get the data. Still some smaller navigation data can be included automatically.
精彩评论