Custom Properties Reset On SaveEntity Call

Posts   
 
    
tracstarr
User
Posts: 8
Joined: 19-Feb-2009
# Posted on: 19-Feb-2009 19:29:35   

I thought I was trying to do something extremely simple, however I've hit a road block.

In short, what I'm trying to do is use a custom Property (SavePreCheck) which does not need to be persisted to the db. I add the property to the partial class of the entity. I then set the property and call SaveEntity on the adapter for that entity.

I override the OnBeforeEntitySave to check that property and perform some pre-save actions. The problem is that the property by this point has been reset to defaults. I would have assumed that this would only occur after the save occurs and reloads the entity, not before.

That being said, I initially thought it might have something to do with serialization. I've tried overriding the SerializeOwnedData/DeserializeOwnedData and OnGetObjectData/OnDeserialized without any luck (they don't even get called).

What am I missing here? How can I go about this?

thanks.

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 19-Feb-2009 21:39:55   

When you say custom properties, are you talking about the custom properties that can be defined in the LLBLGen editor, as documented here ?

Or simply about another member field on the entity ?

If the latter, where are you storing the value for the property? And if you put a "break when value changes" breakpoint on it, can you see it changing from one value back to another...?

Thanks

Matt

tracstarr
User
Posts: 8
Joined: 19-Feb-2009
# Posted on: 19-Feb-2009 22:27:12   

No, not those that can be define in the editor as they are static and won't work on a per entity basis.

I've simply added a property to the entity class

property Something {get;set;}

The only point at which i can break is when the OnBeforeEntitySave is called, at which point it has already changed.

I can only guess that there is something going on inside of SaveEntity that either makes a copy of the entity or otherwise and does the save to that one. ? I had partly thought it was serializing and then deserializing the object within the saveentity method, but if it does, it's not calling the appropriate override functions for serialization. But i could be totally off base here.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 20-Feb-2009 06:24:25   
David Elizondo | LLBLGen Support Team
tracstarr
User
Posts: 8
Joined: 19-Feb-2009
# Posted on: 20-Feb-2009 13:48:43   

Well, like I mentioned, the serialization code isn't even called. I'm also not using web services. However, here is the code used.


 protected override void OnGetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
        {
            info.AddValue("_internalSet", _internalSet);
            info.AddValue("_preparedForSave", _preparedForSave);
            info.AddValue("SkipSavePreCheck", SkipSavePreCheck);
            info.AddValue("HasStatusChanged", HasStatusChanged);
            info.AddValue("NotificationComments", NotificationComments);

            base.OnGetObjectData(info, context);
        }

        protected override void OnDeserialized(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
        {
            _internalSet = (bool)info.GetValue("_internalSet", typeof(bool));
            _preparedForSave = (bool)info.GetValue("_preparedForSave", typeof(bool));
            SkipSavePreCheck = (bool)info.GetValue("SkipSavePreCheck", typeof(bool));
            HasStatusChanged = (bool)info.GetValue("HasStatusChanged", typeof(bool));
            NotificationComments = (string)info.GetValue("NotificationComments", typeof(string));
            base.OnDeserialized(info, context);
        }

I'm using 2.6 final and runtime 2.0.50727

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 20-Feb-2009 18:49:34   

Shouldn't add the underlying private variable instead of the Property?

 info.AddValue("_skipSavePreCheck", _skipSavePreCheck);

The same for the onDeserialized code.

If it fails, please post the code of your Property. Also, You didn't set anything to FastSerialization, right?

David Elizondo | LLBLGen Support Team
tracstarr
User
Posts: 8
Joined: 19-Feb-2009
# Posted on: 20-Feb-2009 19:12:57   

interesting point. I am using properties with simple {get;set;} which defines the variables automatically.... that could possibly be an issue.

That being said, i'm still not convinced it's serialization since these overrides don't get called.

I've also added the appropriate overrides for the fast serialization with no luck (they also don't get called).

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 21-Feb-2009 06:41:30   

That's weird. Could you prepare some tiny project that reflects this behavior, so we can reproduce it? (you can open a private thread at HelpDesk forum and attach the zip file [without dlls], for your code privacy).

David Elizondo | LLBLGen Support Team
tracstarr
User
Posts: 8
Joined: 19-Feb-2009
# Posted on: 21-Feb-2009 19:35:10   

k, i'll put something together. Sick right now though :S

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 22-Feb-2009 11:44:36   

Get well soon simple_smile

Frans Bouma | Lead developer LLBLGen Pro
tracstarr
User
Posts: 8
Joined: 19-Feb-2009
# Posted on: 23-Feb-2009 21:32:51   

gonna be a few more days..... can't look at a screen longer than 10 min. thanks again....

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 24-Feb-2009 08:54:34   

We're sorry to hear about that. I'll close this thread for now, till you come back, just posting a reply will re-open the thread.

Get well soon.