This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
It does not appear that LS supports obtaining the database defaults for a column so what I need to do, only when a new object is created, is set defaults for specific properties. I am trying to figure out the best time to do that other than requiring these items to be passed in when the object is created. Is this possible or should I use the pattern CreateOrder and return a new order object with the properties set? Thanks, Joe |
|
|
In terms of setting them after creation (as part of the LightSpeed-managed entity lifecycle), I think the only hook available at the moment is OnSaving, and we generally advise against modifying state in OnSaving. (It would probably work if you are setting plain data values, not associations / FKs; but it's not a scenario we test.) So creation / initialisation time, whether via the constructor or a CreateOrder factory method, is probably the way to go. |
|
|
Can I add a feature request for 3.0? I would like to be able to override an Creating virtual method or some event that is raised when a new object is created. What would also be nice is a second parameter to that method or event, which tells me if it is being created from a datasource or a user by newing up an object. public virtual void OnObjectCreated(bool createdByUser); The second feature I would like to request is an event or protected method on EntityHolder to tell me when the referece is set. When it is set, to give me the old if it exists and the new object. This way I can perform some data validation. If there is a way to do this now great. May an OnBeforeChange and OnChanged type method or event. Tell me what you think or of you need additional information or justification for these features. Joe |
|
|
I've logged a request for the first feature, though I'm not sure it will be possible to implement (I'm a bit doubtful about whether there's anywhere we could call the creation notification method from in the case where the user is newing up the object rather than LightSpeed creating it). You can get an after-change notification of an association change today via the Entity.PropertyChanged event -- this fires for associations as well as "plain old data" properties. In 3.0 we may add INotifyPropertyChanging to Entity which would give you before-and-after notifications. Would that meet your needs? It does not give you side-by-side old and new values though. Also from your mention of validation it sounds like you may want to cancel the change. Could you say more about what you want to achieve with this additional event? |
|