ObjectContainer.GetChanges() and Server-side business rules validation

4 posts, 1 answers
  1. gmendez
    gmendez avatar
    82 posts
    Member since:
    Jun 2012

    Posted 18 Nov 2009 Link to this post

    Hello,

    I have a distributed application based on WCF. Even I perform data validation at the client side, I also must do it at the server side and I also need to perform more complex business rules validation as well.
    I tryied to pass my data to the server using the ObjectContainer.GetChanges() using the 'Changed' verification mode so the WCF message is as small as possible. That's ok, but in the case of a complex object, sometimes some parts of the object remain unchainged so they are null at the server side (which is obvious). The problem is that some data checks are failing because these 'sub-objects' are null and null values are not allowed in those cases (because of the system requirements). What I really need to do, I think, is to pass only changed objects and their entire network.
    That's the tipical case of an invoice object. Supose I have at the client side an object container with 200 invoice objects. But I change only one, just at the header level. I would like to pass the changed header and all it's children objects  (the whole object network), but NOT the 200 invoices...
    Is there any chance this could be done? If not, i think it could be a great addition for future versions.
    Best regards,

    Gonzalo
  2. Answer
    Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 19 Nov 2009 Link to this post

    Hi gmendez,
    The trick is to first apply the changes to an object scope by using container.CopyTo.
    Lets look and some pseudo code:

    new container
    container.Apply(changeset form client)
    scope.txn.start
    container.CopyTo(scope)
    scope.doallverifications
    scope.txn.commit/rollback

    Even if there is not enough info in the container, you have everything in the scope.

    All the best,
    Jan Blessenohl
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. gmendez
    gmendez avatar
    82 posts
    Member since:
    Jun 2012

    Posted 19 Nov 2009 Link to this post

    ...And thus, the null values would be loaded on demand as they are needed... right?

    Best wishes,

    Gonzalo
  5. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 19 Nov 2009 Link to this post

    Hi gmendez,
    You got it.

    Sincerely yours,
    Jan Blessenohl
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top