Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
UI or BO code?
Message
From
26/08/2010 15:44:12
 
 
To
26/08/2010 14:14:22
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Miscellaneous
Thread ID:
01478134
Message ID:
01478694
Views:
20
>Hi Frank,
>
>I got a better idea. Instead of creating an offline entity and trying to add it back to the business object reference, lets try this:
>1. Get your original entity
>2. Check its status and if you need to create a new one, copy this one to a local reference.
>3. Then just ask the business object to give you a new entity, and copy the values into the business object entity.
>
>Like this.
>
>
> public PolicyEntity GetPolicyByPolicyPK(Guid policyPK)
>        {
>            
>            // get the requested entity
>            this.GetEntity("PoliciesSelectByPK",
>                            this.CreateParameter("@PolicyPK", policyPK));
>
>            // check its status
>            if (this.Entity.StatusFK != (int)StatusCode.Pending)
>            {
>                 // if it is not Pending then create a new entity, copy the data from the original entity 
>
>               // First copy the entity into a local copy so you can keep the values for copy.
>               PolicyEntity oSaveEntity = this.Entity;
>
>               // Now ask the business object to just create you a new entity with default values included.
>               // This entity lives in the business object and should be the current entity.
>                this.NewEntity();
>
>               // Copy over the values you need and change the status.
>                this.Entity.someProperty = oSaveEntity.sameProperty;
>            }
>            
>            return this.Entity;
>        }
>
>This should get rid of the need to try to get your new entity back on the business object reference. Check your business object for HookSetDefaultValues to see what values are being set by default including any Primary Key value.
>Tim

Tim,

I've tried that, but the oSaveEntity values get wiped out when NewEntity() is called. Why would that happen?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Reply
Map
View

Click here to load this message in the networking platform