开发者

How to handle differing validation rules in RIA Services?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜