Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 the [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?

like image 358
Robert Avatar asked Dec 05 '25 15:12

Robert


1 Answers

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.

like image 127
Mark Redman Avatar answered Dec 07 '25 15:12

Mark Redman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!