Entity data field validation and part data submission
I have an entity class that has 10 fields. I am using MS Validation Applica开发者_StackOverflow社区tion block to mark all fields as mandatory (IsRequired). I am implementing a securiy feature in which during updation of the data, not all the fields in the entity class will have data. For example a few users can only view 5 fileds while others all 10 fields during updation on GUI
I have the following options
1) Bring all the data for all the fields from the DB table and hide the ones not accessible to the users in GUI. I am concerned about the performance because everytime GUI will pull unncessary data.
2) Bring the data (e.g. only 5 fields) that are permissible for access/view by the user on GUI. During submit, validation block will throw exception because all fields are marked as IsRequired and only data for 5 fields are sent back to the server.
I want to know if there are any other good approaches to solve problems like this.
I am using .NET 3.5
Thanks.
I don't think it's doable this way.
You should not select data that you don't need and then "hide" them. The selection should be based on roles, users whatever conditions...
You should dynamically change what IsRequired. 'If' statements or other logic. Or use two entity classes...
精彩评论