Actually my point was quite different. Consider this simple scenario where we have Customer-Users with a one-to-many relationship, and my facade provides a method to insert customers.
Let's say I insert a customer. I validate it through validation block, then before calling the data-layer savechanges, I check for duplicate key with a query, something like
if (Context.Customers.Any(c => c.ID == newCust.ID)) // handle not valid
In this case everrything is smooth. But what if my new customer also contains one or more new user? Something like
Customer newCust = new Customer
{
Name = "testCustomer",
Users = new List<User>
{
new User { Username = "test1" },
new User { Username = "test2" }
}
}
This is a common scenario when using the entity framework or something like it. Now let's repeat the procedure with this customer. Everything will be validated, even the users properties thanks to the ObjectCollectionValidator. What will NOT be validated is the "check" for duplicate keys for the users.
But, if I had a duplicate key validator, it would be called like any other validator when the ObjectCollectionValidator kicks in.
Since I consider this a very common scenario, I am wondering if no one else had this problem. I'm sure someone solved it in a good way, and I'd love to hear about it.