Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Commented Feature: How to automatically make EntityValidationErrors bindable? [651]

$
0
0
How can we bind EF EntityValidationErrors so the corresponding WPF grid cells show the errors?

Ex: When DbContext.SaveChanges() throws a DbEntityValidationException with ValidationErrors:
Customer 41
The CustomerId field is required.
The Currency field is required.
Customer 42

we want the display the errors in the grid cells.

With Windows Forms and ADO.NET one simply binds a DataTable to a DataGridView and the DB errors display automatically when pointing at the red exclamation mark.

I there really not code designer to create entities with IDataErrorInfo or an equivalent?

I could not even find an example mapping EntityValidationErrors to IDataErrorInfo or something.

For a detailled discussion see http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/374a2583-8377-4d58-ab12-af305de569b1
Comments: For clarification: my original question was not about how to implement validation but on how to use existing DB validation results easily with data binding - as easy as in Win Forms / ADO.NET. In many applications we solely rely on DB validation and dont code any validation in the apps. A common scenario is displaying multiple different validation errors for different entities in an editable grid as a result of a call to a coarse grained service interface.

Viewing all articles
Browse latest Browse all 10318

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>