Question

I'm using the LinqtoSQL for a WPF M-V-VM application, as I might want to change from LinqtoSql to something else in the future, like Entity framework or Subsonic etc, thus I found repository pattern to be helpful,

My question is how do I create the model classes, suppose I have an table in the database, I understand that I cannot use the LINQtoSQL generated Class as the model class, if I do, then I would become dependent on LinqtoSQL, which inturn would take away the independence that I would have of implementing the repository pattern, does that mean that I would need to have my own custom classes for all entity classes?

Was it helpful?

Solution

Good lord, no. Why would you do that to yourself?

You've already got to duplicate so much in your ViewModels, why would you add another layer of duplication for so little gain, especially considering L2S can use plain ol' clr types?

I consider both my service contracts from WCF services and ORM types to be my model. Just because it doesn't reside in a *.Model namespace doesn't mean a thing.

If you feel like you need this lubricating layer, let that layer be your ViewModels. That's what they are there for.

OTHER TIPS

Yes, it means that you need to implement you own custom classes for all entity classes. It's a pain, but that's the current state of things.

See this SO answer for more information on the subject, and some possible remedies.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top