Please read my update at the end of question after reading the answers:
I'm trying to apply repository pattern as Rob Conery's described on his blog under "MVC Storefront". But I want to ask about some issues that I had before I apply this design pattern.
Rob made his own "Model" and used some ORM "LINQ to SQL or Entity Framework (EF)" to map his database to Entities.
Then he used custom Repositories which gives
IQueryable<myModel>
and in these repositories he made sort of Mapping or "Parsing" between ORMEntities
and hisModel
classes.What I'm asking here:
Is it possible to make custom mapping between ORM
Entities
and my model "classes
" and load just properties that I want? I hope the point is clear.
Update For POCO
**
**
After all and with respect to Mr. Rob Conery's opinion I've got better solution as:
POCO
s" and put them in my "Models Layers" so they had nothing to do with the "edmx" file.POCO
" model dependent on "DbContext
"ViewModels
" to get just the information that needed by view from those repositories.So I do not need to add one more layer to be between "EF Models" and "My Model". I just twist my model a little and force EF to deal with it.
As I see this pattern is better than Rob Conery's one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With