Possible with Validation Block??

Topics: Building and extending application blocks, General discussion, Validation Application Block
Aug 20, 2009 at 5:22 PM


I have a collection of MyObjects.  Field1 and Field2 of MyObject form part of the primary key used on the database. 

public class MyObject
    public string Field1 { get; set; }
    public string Field2 { get; set; }

    public string Field3 { get; set; }

Is it possible to validate the collection using the Validation Block, so that the validation results returned for each failing object are something along the lines of "Duplicate Key Detected for Field1 + Field2 key"?

I don't believe it is, but I want to check before I implement anything.  Ideally I am looking to make the configurable via XML.



    <UniqueKey Name = "UniqueKey1">
        <Field Name = "Field1" />
        <Field Name = "Field2" />






Aug 24, 2009 at 7:03 AM

Yes. That would also be my thought. I was thinking maybe the validation part would be possible by implementing your own validator, but I'm not totally sure if that will work.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.

Aug 25, 2009 at 1:33 AM

It is possible to validate a collection of object using VAB but since there's no built-in validator in entlib that can handle the validation logic that you want, you would definitely need to create your own validator.  You can then create your own validation message.


Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.