开发者

How to handle differing validation rules in RIA Services?

开发者 https://www.devze.com 2023-01-20 11:18 出处:网络
We have an Entity Framework model that is used by two different silverlight applications.The validation rules are very similar in the two contexts, but differ slightly.

We have an Entity Framework model that is used by two different silverlight applications. The validation rules are very similar in the two contexts, but differ slightly.

For example, a regular user in one of the applications cannot input time that is in the future, but an administrator in the other application can put time that is in the future.

How would you handle designing this application? Two ideas we came up with:

  1. Creating two entire开发者_StackOverflow社区ly separate models, so that each can be independent
  2. Share the same model, but put a "Context" property on our base Entity class, so that the validation rules can validate differently where necessary.


I have never tried it, but what about extending or creating new validation attributes that uses a different validation depending on the authorisation role of the user?


Those sound like business rules which should be seperate from data access. You should be able to use the same EDM but implement the business rules in the business layer, not the data layer.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号