有没有办法在使用wcf ria时选择性地跳过silverlight字段验证? [英] Is there a way to selectively skip silverlight field validation when using wcf ria?
问题描述
您可能需要在此处查看ValidationContext容量。您可以具有根据实体或任何其他要提供的属性进行决策的验证属性。
查看我提供ValidationContext和使用ValidationContext的博文:
http:/ /jeffhandley.com/archive/2010/10/25/RiaServicesValidationContext.aspx
http://jeffhandley.com/archive/2010/10/25/CrossEntityValidation.aspx
希望这有帮助,
Jeff
I have a (likely common) case where I would like to reuse the same class for both adding a new entity and editing an existing entity in my silverlight app (SL4, WCF RIA, EF4, Linq-to-Entities). When adding a new one, I would like my custom validator to check for uniqueness and fail if it's not unique. However, when editing, I don't want that same validator to prevent edits. Is there a way to temporarily turn off validation for a single field (ideally by validation type so that the other validators can still run on that same field)?
You might want to check out the ValidationContext capabilties here. You can have validation attributes that make decisions based on properties on the entity, or any other state you want to provide.
Check out my blog posts on Providing ValidationContext and Using ValidationContext:
http://jeffhandley.com/archive/2010/10/25/RiaServicesValidationContext.aspx
http://jeffhandley.com/archive/2010/10/25/CrossEntityValidation.aspx
Hope this helps,
Jeff
这篇关于有没有办法在使用wcf ria时选择性地跳过silverlight字段验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!