开发者

Is it good to create static DomainContext in Silverlight Application?

I am developing Silverlight application. I create static DomainContext in my application, so there are only one for each DomainContext. When I use application for a while, DomainContexts seem like to keep data inside it, for example, when I search data and it return 100 records it will keep these data until I clear it manually.

  1. Is it good to create DomainContext as static and reusing it for the life of application?
  2. If it's good to has one DomainContext instance, how can I deal with bloat Contex开发者_如何学运维t problem?


  1. One DomainContext is a good idea because you can't/shouldn't share entities between different DomainContext objects, if you try to do it program will fail.

  2. Any time you have data that it's not necessary at given point and that is synchronized with server, use DomainContextObject.UnnecessaryEntities.Clear() method. Also you should ask yourself a question how many records should be sent to client, 100 seems to be a lot if you're going to present them, paging could be easily done from server side so you can send less data over the network. Another point is how much memory those records can take (I guess that's it's nothing when compared to average client RAM capacity)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜