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.
精彩评论