This is a migrated thread and some comments may be shown as answers.

Ignore IInstanceCallbacks PreStore when flushing changes

3 Answers 39 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Stijn
Top achievements
Rank 1
Stijn asked on 29 Jan 2015, 02:56 PM
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

3 Answers, 1 is accepted

Sort by
0
Ady
Telerik team
answered on 02 Feb 2015, 09:49 AM
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.
 
0
Stijn
Top achievements
Rank 1
answered on 11 Feb 2015, 10:24 AM
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
0
Ady
Telerik team
answered on 16 Feb 2015, 10:55 AM
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.
 
Tags
Development (API, general questions)
Asked by
Stijn
Top achievements
Rank 1
Answers by
Ady
Telerik team
Stijn
Top achievements
Rank 1
Share this question
or