Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
UI or BO code?
Message
From
25/08/2010 14:10:45
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
 
To
25/08/2010 13:48:52
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Miscellaneous
Thread ID:
01478134
Message ID:
01478430
Views:
20
>>Hi Frank,
>>
>>Yes, that is what I meant and I see no reason what you did wouldn't work fine.
>>Tim
>>
>
>Hi Tim,
>
>I've been trying this out and am getting a bit lost.
>
>My UI code is this:
>
>
this.oPolicy.GetPolicyByPolicyPK(this.PolicyPK);
>
>The code in my BO is this:
>
>
        public PolicyEntity GetPolicyByPolicyPK(Guid policyPK)
>        {
>            //return this.GetEntity("PoliciesSelectByPK",
>            //    this.CreateParameter("@PolicyPK", policyPK));
>            
>            // get the requested entity
>            PolicyEntity oPolicyEntity = this.GetEntity("PoliciesSelectByPK",
>                            this.CreateParameter("@PolicyPK", policyPK));
>            // check its status
>            if (oPolicyEntity.StatusFK != (int)StatusCode.Pending)
>            {
>                // if it is not Pending then create a new entity, copy the data from the original entity 
>                PolicyEntity oNewPolicyEntity = new PolicyEntity();
>                //CopyPolicyEntity(oPolicyEntity, oNewPolicyEntity);
>
>                // return the new entity
>                return oNewPolicyEntity;
>            }
>            else
>                return oPolicyEntity;
>        }
>
>Stepping through the code shows me that oNewPolicyEntity is getting returned. This has no values set in it (I have not done the code to copy anything yet), yet when I return to the UI my oPolicy has the values for the original policy. This actually brings me to one of the confusions I have. In VFP I would have to store the return value somewhere, but this code does not store the returned PolicyEntity anywhere, so how does the this.oPolicy.Entity get populated with the data and why isn't it showing the new/blank policy data?

Frank, when you use the business object methods to retrieve an entity or entity list they are stored on the business object collections. If you retrieve an entity into a local reference the way you did, that may not be the case. Try doing this instead.
 public PolicyEntity GetPolicyByPolicyPK(Guid policyPK)
       {
           
            
            // get the requested entity - leave on the business object for return in the event we need it.
            this.GetEntity("PoliciesSelectByPK",
                            this.CreateParameter("@PolicyPK", policyPK));

            // check its status
            if (oPolicyEntity.StatusFK != (int)StatusCode.Pending)
            {
                // if it is not Pending then create a new entity, copy the data from the original entity 
                PolicyEntity oNewPolicyEntity = new PolicyEntity();
                //CopyPolicyEntity(oPolicyEntity, oNewPolicyEntity);

                // Clear the current entity list and add this one instead
                 this.EntityList.Clear();
                this.EntityList.Add(oNewPolicyEntity);
            }
            // This will return either the original or the newly created one that is added.
           return this.Entity;
}
Timothy Bryan
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform