views:

149

answers:

1

Does anyone know of any way to insert in business validation rules within entity frmework? Ideally I want to use dynamicData across some portions of a EF model, and then handle securing access with the EF model itself.

For example, if looking at orders, I want to add in a rule that customers can only view their own companys orders.

Is this possible?

+1  A: 

We do it with the Service and Repository patterns. There's a basic example here [PDF]. Regading Dynamic Data, I strongly suggest binding to view models, not entities.

Craig Stuntz
Yes, with EF4 planning to only expose POCO via repository pattern, and probably use a domain service to fully restrict / control.For dynamic data though without using the futures build, I need a work around. Do you have any examples of mapping to view models rather than entities - not come across that approach as the scaffolding seems to be bypassing any layering or intercepts I have tried (ie http://code.msdn.microsoft.com/EFPocoAdapter)
I use MVC 2 Dynamic Templated views rather than Dynamic Data *per se.* It's the same technology, but *much* more flexible.
Craig Stuntz