Object

Object

Old forum URL: forums.lhotka.net/forums/t/5552.aspx


KJosh posted on Tuesday, October 07, 2008

Hi,

I have define one class

Class A : BusinessBase<A>

{

//Properties

}

I have another class B which is also inheriting from BusinessBase.

Now In my Class C, I am including the objects A, B as the properties. In the classes A and B, I want to put the Insert/Select/Delete/Update methods. From the user interface, I am calling Save like the below:

C objc;

objc.Save() -> calls the DataPortal_Insert, Dataportal_Update in the class C. Now In these methods, I want to call the Insert/ update methods defined in A and B. How to do this?  I need this type of functionality because, in my User interface A and B functionality is the part of C.

Thanks in advance

sergeyb replied on Tuesday, October 07, 2008

Project tracker has this exact scenario.  Look at Project class -> DataPortal_Update() method.  You will see call to UpdateChild.

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: KJosh [mailto:cslanet@lhotka.net]
Sent: Tuesday, October 07, 2008 8:43 PM
To: Sergey Barskiy
Subject: [CSLA .NET] Object

 

Hi,

I have define one class

Class A : BusinessBase<A>

{

//Properties

}

I have another class B which is also inheriting from BusinessBase.

Now In my Class C, I am including the objects A, B as the properties. In the classes A and B, I want to put the Insert/Select/Delete/Update methods. From the user interface, I am calling Save like the below:

C objc;

objc.Save() -> calls the DataPortal_Insert, Dataportal_Update in the class C. Now In these methods, I want to call the Insert/ update methods defined in A and B. How to do this?  I need this type of functionality because, in my User interface A and B functionality is the part of C.

Thanks in advance



KJosh replied on Tuesday, October 07, 2008

Hi,

I found this line in the Project's DataPortal_Update:

DataPortal.UpdateChild(ReadProperty<ProjectResources>(ResourcesProperty), this);

But the ProjectResources does not have any DataPortal Update/insert methods.

a) Here which method the above line is actually executing? ProjectResources is the collection of ProjectResource objects, which contain update/insert methods.

b) The Project class contains the  ProjectResources resources as one property which is having only Get method with no set method, then how it is updating the resource data?

Thanks for your time.

sergeyb replied on Wednesday, October 08, 2008

UpdateChild is smart enough to figure out that it needs to update the list, so it runs through each item in the list, executing Child_XXX on each one.

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: KJosh [mailto:cslanet@lhotka.net]
Sent: Tuesday, October 07, 2008 10:57 PM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] RE: Object

 

Hi,

I found this line in the Project's DataPortal_Update:

DataPortal.UpdateChild(ReadProperty<ProjectResources>(ResourcesProperty), this);

But the ProjectResources does not have any DataPortal Update/insert methods.

a) Here which method the above line is actually executing? ProjectResources is the collection of ProjectResource objects, which contain update/insert methods.

b) The Project class contains the  ProjectResources resources as one property which is having only Get method with no set method, then how it is updating the resource data?

Thanks for your time.



KJosh replied on Tuesday, October 07, 2008

Hi Sergey,

If you have a chance, could you give your opinion on this qustion:

http://forums.lhotka.net/forums/thread/26925.aspx. which is also similar to this one.

sergeyb replied on Wednesday, October 08, 2008

I like a) approach better but only from usability perspective.  If I were a user working on a single employee, I would expect to save changes to employee’s data by clicking on single Save button regardless of what tab they were made at as part of a single transaction.  And yes, you can share transaction between unrelated objects, it just not as clean (IMHO) as approach a).

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: KJosh [mailto:cslanet@lhotka.net]
Sent: Tuesday, October 07, 2008 11:00 PM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] RE: Object

 

Hi Sergey,

If you have a chance, could you give your opinion on this qustion:

http://forums.lhotka.net/forums/thread/26925.aspx. which is also similar to this one.



Copyright (c) Marimer LLC