Ria Services Navigation property add validation RRS feed

  • Question

  • Hello,

      My application has a 1:N parent child entities and I am providing access to only the parent entity and am using the composition attribute to include those child entities. I need to run some validations when I try to add a child entity to the child entity collection. So, I have tried adding a custom validation attribute the the navigation property and decorated it with composition attribute also and still it is not working. Can someone tell me if there is way to do the validations when I try to add a child object to that entitycollection.


    Thursday, June 9, 2011 12:01 PM


All replies

  • Can someone please reply to my post and through some light to clear my doubts. I have searched online but could not find any good resource.

    For a single parent entity I have aroung 30 child entities to which i need to run these these validations when I add an object. Currently it seems I have to cast these entiy collection objects of an instance(which means i have to register these events every time i create an object) and add these validations on  the client side explicitly as RIA Services does not seem to project and handle the custom validations on the entitycollections, like the validations on other property types, on the client side. Can anyone please tell me if there is any standard way of handling this kind of scenario. 

    Friday, June 10, 2011 11:42 AM
  • Hi Ajay,

    Could you please explain what kind of validation you want to impelment?

    For a single parent entity I have aroung 30 child entities to which i need to run these these validations when I add an object.

    Why each child entity has its own validation?


    Best Regards,

    Wednesday, June 15, 2011 5:31 AM
  • Hello Shi Ding,

      Thanks for the reply. It feels so nice to be heard by someone finally :).
    Here is how my scenario goes. We have some validation rules for these child entities. As I mentioned all these are in 1:N relation with the parent entity. So, one rule is to make sure there is no duplicate child entity and other rules defined as per our application requirements like, if that child entity is a first record then it can be allowed to have true value for the unavilable(a property/column in child entity/table) and some other rules set on the child entity based on the previous records and sometimes dependent on the other child entities or the parent entity.
    So I was thinking if there is a more elegant way in handling this kind of scenario to handle the collection changed event or some kind of work around so that we can code normally expecting the validations run at some point before submitting to the server. I was thinking of using the custom validation on the parent entity and run these validations but there is a dependecy on another object to read all these validation rules. I am stuck on this issue. Can you please tell me how I can handle this scenario ar atleast point me in a right direction?


    Wednesday, June 15, 2011 10:49 AM
  • Hi Ajay,

    There is an Entity Graph on CodePlex which supports entity collection validation.

    For details, please have a look at below link



    Best Regards,


    Wednesday, June 15, 2011 11:28 PM
  • Thank you Shi Ding.
    I have already looked into the Entity Graph example and I am sure that is the best possible solution so far. But I am afraid I have to use MEF to take advantage of the entity graphs which is not in our application design plan as of now and so we would have to identify the overload MEF brings to our development time and look into the pros and cons of using it.Thanks,


    Thursday, June 16, 2011 1:19 PM