Ignore IInstanceCallbacks PreStore when flushing changes

4 posts, 0 answers
  1. Stijn
    Stijn avatar
    4 posts
    Member since:
    Oct 2014

    Posted 29 Jan 2015 Link to this post

    Hello,

    Before saving an object, i want it to do some validation. I thought of using the PreStore method from the IInstanceCallbacks interface to achieve this behaviour. However it seems the PreStore is also executed when flushing changes which results in faulty validation as the object isn't 'ready' yet. Is there a way to know is the PreStore is called because of a flush or a save?

    Kind regards,
    Stijn
  2. Ady
    Admin
    Ady avatar
    589 posts

    Posted 02 Feb 2015 Link to this post

    Hello Stijn,

     I'm afraid the API does not provide the information if the callback is called during a Flush or SaveChanges call although this is something you could very easily track within your code by setting a flag within encapsulated calls to Flush and SaveChanges.
    I am not aware of the validations that you are performing but was wondering if the 'Context changes tracking' API would help in any way.

    Do get back in case you need further assistance.

    Regards,
    Ady
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  3. DevCraft banner
  4. Stijn
    Stijn avatar
    4 posts
    Member since:
    Oct 2014

    Posted 11 Feb 2015 in reply to Ady Link to this post

    Hello Ady,

    Unfortunatly the 'Context changes tracking' API is of no use as validation can only be done after i'm sure all changes that need to be made are made. I can of course manually call a validate function at the end of any changes that are being made but then i'd have to remember to write the validate on every function that makes changes.

    Setting a flag is an option I will look into. Having this flag available in the IInstanceCallbacks methods however would be a much cleaner solution and possibly something to note for future versions?

    Kind regards,
    Stijn
  5. Ady
    Admin
    Ady avatar
    589 posts

    Posted 16 Feb 2015 Link to this post

    Hi Stijn,

     Thank you for your feedback. You can create a feature request on our feedback portal here to allow others to up-vote the request.

    Do let me know if you need further assistance.

    Regards,
    Ady
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
Back to Top