开发者

Domain entities into (ASP.NET) Session, or better some kind of DTOs?

Currently we put domain objects/entities into our ASP.NET sessions.

Now we considering moving from InProc sessions to state server. This requires that all objects inside session are serializable. Instead to annotate all objects with th开发者_C百科e [Serializable] attribute, we thought about creating custom-session objects (DTO Session Objects?), which only contain the information we need:

CONS:

  • Entities must be reloaded, which requires additional DB round-trips

PROS:

  • Session State is smaller
  • Session information is more specific (could be a CON)
  • No unneeded annotation of Domain-Entities

What do you think? Should we use some kind of DTOs to store inside the session, or should we stick with good old entities?


If you are thinking of moving to ASP.NET MVC, these DTO's become your Model ViewData Objects, which could make for a handy migration.

Yes, Session info wil lbe more specific as DTO's will be specific to the behaviour of it's usage. It should reduce the overhead in not having unused info or even restricted info.

Specifc DTO's will also help with other things; If you implement other technologies in your presentation layer, eg Silverlight, Flash etc and need the same objects in a webservice.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜