Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Shaped Entities
Message
 
To
19/12/2008 10:42:46
Tegron Tegron
Platinum Technologies
Ohio, United States
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Environment versions
Environment:
ASP.NET
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01368835
Message ID:
01369256
Views:
16
Tegron,

I will jump in here and see if I can help.

What I have done is create two business objects for this situation. The first is based on the table (e.g. Orders) and is generated with the BO generator. It ends up with the 4 classes (Main class, Entity class, Rules class and defaults class) and with the data access class as well. This object does not contain the referenced columns (or description columns) for the foreign key colums (this is your dilemma).

I then create a view in the database (e.g. vOrders) that contains all the columns in Orders as well as the joined description columns from all the foreign key reference table columns. This view now contains all the values I want to display in a grid on a form.

Next, I use the BO generator to generate the necessary classes for use in my grid. However, all that is needed is to generate two classes. Those are the main class and the Entity class. There is no need for the Rules or Default classes and also no need to generate data access classes.

Lastly, I create any needed stored procedures (I never use SQL statements in my BO classes) for any combination of parameters, etc.needed by the application and then create the methods needed in the main class for retrieving the data needed in the app.

For example, here's a stored procedure:
CREATE PROCEDURE [dbo].[OrderViewSelectByCustomer]
(
	@CustomerName char(20)
)
AS
	SET NOCOUNT ON;
	SELECT *
	FROM [dbo].[vOrder]
	WHERE 
		([CustomerName] like (rtrim(@CustomerName) + '%'))
... and here's the method placed in the vOrder class:
public mmBindingList<VOrderEntity> GetOrderByCustomer(string customerName)
        {
            return this.GetEntityList<VOrderEntity>("OrderViewSelectByCustomer",
                this.CreateParameter("@CustomerName", customerName));
        }
This approach worked very well in my app which is web based due to the way I designed it. I have list forms using grids that show the data from the view entities on a main form. This main form then will be able to select an existing record (or add a new record) and launch an edit form which used the first business object based on the table and uses combo boxes for the foreign key fields in the business object.

I am now coding a windows app for this same business object library and see there is a challenge for this using windows forms since the maintenance business form for MM will have the grid and edit form on the same form class (unlike the web based). I think I can get around this by placing both business objects in the form (using the table based object as 'Primary') and using the view based object for the List Grid and placing some extra code in the form to synchronize the grid with the Properties page.

I will let you know how this goes.

HTH


>Can anyone provide the exact way to setup and use a different shaped entity? The documentation is very vague regarding this area. The doc shows how to get items into the entity and how to create a new entity object, but it does not show how to use the different shaped entity with the business object.
>
>I want to use the different shaped entities in grids that displays the names instead of the coded values. I am thinking the shaped values will allow me to use any type of stored proc that I would like with a business object instead of being limited by the default entity for the business object. If anyone has any other suggestions, I would appreciate it.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform