简体   繁体   English

EF-> RIA服务-> Silverlight,我可以显示验证错误消息,但仍保存更改

[英]EF -> RIA Services -> Silverlight, Can I show validation error messages but still Save changes

I am using Entity Framework 4.0, RIA Services, and Silverlight 4.0. 我正在使用Entity Framework 4.0,RIA Services和Silverlight 4.0。 I need the user to be able to save any changes regardless if they are correct or incomplete. 我需要用户能够保存所有更改,无论它们是正确的还是不完整的。 To do this I had to make a lot of fields in the database nullable. 为此,我必须使数据库中的许多字段为可空。 I still want to be able to show validation error messages in the Silverlight client to the user. 我仍然希望能够在Silverlight客户端中向用户显示验证错误消息。 What I would like to do is use DataAnnotations to attribute the entities metadata in Ria Services to get the nice validation error messages on the client but I need the user to be able to save even if it breaks validation. 我想做的是使用DataAnnotations在Ria Services中为实体元数据赋予属性,以在客户端上获得漂亮的验证错误消息,但是我需要用户能够保存,即使它破坏了验证。 Is this possible? 这可能吗? How would I go about implementing this? 我将如何实施呢?

Thanks, Evan 谢谢,埃文

In Silverlight there is no such thing as warnings-only Data Annotation Validators. 在Silverlight中,没有诸如仅警告的数据注释验证器之类的东西。 In ASP.NET you could get your intended outcome using a CustomValidator that was simply client-side JavaScript, but no such equivalent is present in Silverlight. 在ASP.NET中,可以使用只是客户端JavaScript的CustomValidator获得预期的结果,但是Silverlight中没有这样的等效项。 Your best bet is to program this logic into the form itself or create a custom control which allows you to decorate an existing control much in the way that the ToolTipService works. 最好的选择是将此逻辑编程到窗体本身中,或者创建一个自定义控件,该控件使您可以以ToolTipService的工作方式来修饰现有控件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM