ASP.Net MVC, ORM, and heavy objects

I think this problem is common in web applications with an average model. Say I have a SportCenter class that contains a BasketballField list when showing reservations or properties of a basketball field. I still want to show some information about the SportCenter to which it belongs.

I use ASP.Net MVC and nHibernate for the data layer, so my question is: is it worth loading nHibernate the entire SportCenter instance (actually contained in the collection, lazy, but still the class is “heavy”) along with my BasketballField and its information so that Show only a few Sportcenter fields?

On the other hand, building very finely tuned queries in HQL brings me back to the old Classic ASP days with manual SQL queries ...

Any best practice to offer?

Thanks, Peter.

+3
source share
5 answers

I am becoming a strong proponent of the separation of commands / queries (Greg Jung's version), so I would say that if you want to display data for the user (Query), you definitely should not use your domain model. Getters are quite often anti-patterns when it comes to a good domain.

Currently, I prefer to use on-screen DTOs filled with NHibernate. They work best when disconnecting a single table, but you can use NHibernates AliasToBeanTransformer to populate from your domain table.

0
source

, , . , Red Gate ANTS Profiler, , .

, , - SportCenter - HQL.

IMHO, OR/Ms, , SQL/.

+2

, " " SportCentre, BasketballField ( BasketballField SportCentre).

, , nHibernate, , , .

0

Linq. NHibernate Linq. Linq , " " , .

, , , " " .

person-b, , .

DTO - , , .

0

, . ViewModel.

0

Source: https://habr.com/ru/post/1716607/


All Articles