subject:
REST(Asp.Net MVC) and LLBLGen; Entities vs POCO's
post:
Hi.
I have been thinking about this for a week and can't decide at all wether i should use POCO classes or the entities itself as models for my MVC web application.
Actually i have a working _DSL _that generates metadata, security predicates and manages persistence from request to post for my entities so that they can be used as MVC models.
What i like of using entities as models:
-
The model has all the metadata; I am using the designer to add all security and validation metadata as attributes so i can generate all the needed metadata-classes, data providers (they are just linq metadata providers that adds some default predicates for security and soft-delete)
-
Saves work; I did a simple 'EntityValidationAttribute' that maps MVC to LLBLGen validations so it validates per-field and per-entity using JS validation when available.
Why i don't:
-
LLBLGen is not REST; what i do is to fetch the entity using a unique id passed as a parameter in the web request and then merge the entity returned by MVC (it has only the view fields filled). This creates a problem if some validation requires of fields not added to the view to perform and also its not as straight forward as i would like it to be.
-
DSL's code is starting to be a mess. Always controlling if the entity was loaded from the database or comes from a view response not too straight-forward.
-
The application is a service oriented application. Initially it won't be a WCF service, just a class but we may want to change it into a WCF service later, using complex types like EntityBase as return type or parameters doesn't seems to be a good idea.
-
I like S.O.L.I.D. development but using llblgen entities as models it feels like i lost the O and the L, not much important here because we know llblgen and i am shure that there's nothing that would lead us to change it by another ORM in that particular application.
-
Using poco's the model designer won't be a bottleneck to the front-end development.
--
Actually just writing the post helps me in taking the decision but would like to read any comment or advice about this.
Thanks.
Aridane Álamo.