Hi,
I was wondering if someone could give me some advice regarding some CSLA design issue I am having.
Supposed that you have two classes with the following properties as follows:
Class Car
{
String Model;
Int Year;
CarEngine TheEngine;
}
Class CarEngine
{
Int HorsePower;
Int NumberOfCylindes;
}
The classes above are just **make believe**, overly simplified classes to **illustrate** the issue.
In order to make my life simpler, I decided that I was going to have one table containing columns to hold all the info for the classes listed below as follows:
Table Columns:
Model
Year
HorsePower
NumberOfCylindes
And there lies my predicament. I am currently using the Car class to implement all DataPortal_XYZ methods, so when the time comes for saving the data the DataPortal_Update function on my Car class gets the values from the CarEngine class and plops them in the one table.
So I have zero DataPortal_XYZ methods on the CarEngine class and for some reason that feels somewhat disturbing to me, like if I was doing something wrong since it does not fit the template.
What do you guys thing, any one has any suggestions?
Thanks.
I have done something similar. I have a top level BO that represents 28 of 30 columns in a table. It contains a child object that represents the other two. The child object has special code in it to store a byte array into a column in the same row. It also stores a text string related to the byte array. (Think Image and contentType.)
The top level BO does an Insert for the 28 fields and omits the other 2 fields from the SQL. The DB fields are nullable or have default values. Then the child does and Update of the newly created row but only sends the data for the two fields. It gets the rowId from the parent.
The main reason I did this is that sending a byte array to SQL Server is best done with parameterized SQL. My standard SQL is dynamic and you can;t really mix the two styles. This has worked out quite well and the top level BO is used in many places and the byte array changes to whatever is required. (Logo image, form image, etc.)
Joe
Copyright (c) Marimer LLC