Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Clean way to reference 'current' entity?
Message
From
19/08/2008 15:14:13
 
 
To
19/08/2008 10:18:01
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
VB 9.0
OS:
Vista
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01339837
Message ID:
01340077
Views:
9
>Larry,
>
>>Hi Kevin/Tim/All, me again.
>>
>>In the Northwind sample application, let's say I wanted to add a button on the employee form that calls oEmployee.ShowLast in Employee.Partial that can do something like console.writeline("The employee LastName is: " + LastName ). (I know it can be done directly from the employee form, but I'm trying to sort out a clean approach to accessing that current row data from the business object.)
>>
>>
>>I've tried two approaches
>>
>>1): pass the unique key and within the bizobj create a new emp Employee collection, then do an emp.get based on the primary key. This works but the calling form list becomes the new list of 1 record from the database.
>>
>>2) in the employee form, do a foreach ent loop through oEmployee.entitylist, looking for the unique key, then set entindex = oEmployee.EntityList.IndexOf(ent), then call oEmployee.ShowLast(oEmployee.EntityList[entindex]) passing the entity.
>>
>>Both approaches seem suboptimal, seems fundamental, I must be missing something obvious.
>>Any suggestions?
>>
>>thanks,
>>Larry
>
>When you say "oEmployee.ShowLast" are you talking about showing the last name?
>If you are on the current record then you shouldn't have to call into the business object to get that value. Also if you are displaying something it wouldn't really be a business object task unless the BO needs to obtain new data for you.
>
>This should get you the info for the current record.
>Debug.WriteLine("The employee Last Name is: " + oEmployee.Entity.LastName);
>
>I am not sure I answered your question, but tried. :-)
>Tim

Hi Tim,
okay sorry I goofed in trying to simplify my question, wasn't a good example. It's the child entities that seem to cause this problem.

Instead, add a button to CustomerOrdersForm called btnShowOrderDetailLine. Have it call OrderDetail.ShowOrderDetailLine. In OrderDetail.Partial add public void ShowOrderDetailLine() {console.writeline(" ->order line ProductID is: " + this.Entity.ProductID);}

On an order with multiple detail lines, OrderDetail.Entity is always the first entity, regardless of which is selected. So if I have the second line selected, I'd really be after this.EntityList[1].ProductID. Course they could be sorted so I have to be careful with the index.

So the question is how can I call that with the selected entity (order detail line) instead? I'm thinking there is no currentindex type value in the entity for those child records.

To answer your other questions: I'm justing using the console.writeline as a first step to getting the reference correct from within the bo. The actual code that I'd be doing (using these details) is to generate records elsewhere using values from the selected child record. It's in the BO since it's that business objects responsibility to create the records, not the user from the user interface.

thanks,
-Larry
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform