This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, Not sure if this is expected behaviour or not; I've got an entity which is being updated via mvc (using the community modelbinder stuff). The entity has a FK to a lookup table and we're using Guids for identity. So I've got a Record entity which has a bunch of normal properties, and non-nullable relationships to a Classification entity and a User entity. And btw, the Record.User is not editable via the UI. When the incoming form doesn't have a valid value for ClassificationId, an error is added to the validationerrors collection. That's what i expect to see. But what I didn't expect was to see that there is actually another error against the Record. Because the Record is not valid and the User has a backreference to the Record, the User then shows as having an Error (which is that the child Record is not valid). And because the User is not valid, it is added to the Record validationerrors. It seems sort of circular... This is a problem in mvc using the standard validation summary because there are now error messages for Classification (which i do want) and User (which i don't want). So;
cheers justin
|
|
|
Hi Justin :) Currently the ModelBinder is fairly generic in passing through errors against the entity through to the model state collection, so it will literally contain every error that LightSpeed has assigned against that entity. As you have found, LightSpeed propegates its errors so that if an entity depends on another entity, and that entity is not valid, then that itself becomes an error, and both sides of the association will be saying that each other is not valid. So, 1. Yes - it is expected 2. No 3. Yes, the improvement to make here would be to identify the errors on defendant objects using a regex and strip them from the collection. If you are keen, you could look at doing this and send through a patch, otherwise I can do this after the Easter break.
Jeremy |
|