StrataFrame Forum

FillByStoredProcedure v. BOM

http://forum.strataframe.net/Topic23321.aspx

By Alex Luyando - 6/3/2009

Greetings.



Two questions about business object mapping and FillByStoredProcedure( )...



1.) In a reply somewhere out here (I believe possibly from Ben) there was a indication that the BOM would allow mapping of a business object to a stored procedure as part of the 1.4.1 release. I'm not seeing anything that would allow that, and am running the 1.6.7. Was that option scratched, or is it hiding from me?



2.) Not withstanding new information I may get from replies to the above, I have a business object mapped to a SQL Server table. I will be giving users UI controls that will eventually trigger a call to BO Fill methods that will wrap calls to FillByStoredProcedure( ). Do the stored procedures called need to return datasets that are positional with respect to the columns the BOM knows about (i.e., data fields must be in the same sequence as the CreateTableSchema( ) in the BO's designer file), or have the same column/field names?



3.) Let's talk Browse! How would I go about customizing the Browse dialog to allow for searching based on columns not mapped in the BOM? This question will, of course, lead to discussions about the new OverrideSearchTableName/Schema, which I will look at. That may or may not be the solution, depending on whether--for my purposes--I can setup a view (or, I guess, views and programmatically change the Override.... properties just before calling the BD.showDialog()) that handles all possible searches the users will want to construct. If it does, great. If not, I'm hoping the flexibility of calling a stored procedure from the BD is feasible.



TIA
By Trent L. Taylor - 6/3/2009

1.) In a reply somewhere out here (I believe possibly from Ben) there was a indication that the BOM would allow mapping of a business object to a stored procedure as part of the 1.4.1 release. I'm not seeing anything that would allow that, and am running the 1.6.7. Was that option scratched, or is it hiding from me?




Pulling from a stored procedure is not a possibility (at least for now) as this would require a number of things to be changed including the ability to setup parms as part of the mapper to retrieve the query. Since a SPROC is not an actual mapped schema element, it cannot be directly mapped. However, you CAN map to a view. This may have been the post to which you were referring.



2.) Not withstanding new information I may get from replies to the above, I have a business object mapped to a SQL Server table. I will be giving users UI controls that will eventually trigger a call to BO Fill methods that will wrap calls to FillByStoredProcedure( ). Do the stored procedures called need to return datasets that are positional with respect to the columns the BOM knows about (i.e., data fields must be in the same sequence as the CreateTableSchema( ) in the BO's designer file), or have the same column/field names?




First, on this point, you will most likely be better off just calling FillDataTable and building a the command versus using the FillBy StoredProcedure method. You will have more contrl this way. For example:



SqlCommand cmd = new SqlCommand("dbo.MyStoredProcedure");



//-- Set the command type (this will force the command to execute a SPROC versus an SQL statement)

cmd.ComandType = SqlCommandType.StoredProcedure;



//-- Add any parms

cmd.Parameters.Add("@parm1", SqlDbType.BigInt).Value = Val1;



//-- Now fill the BO with the result set

this.FillDataTable(cmd);




The second part of your question. If you are going to be using the fieklds to which you have mapped (instead of a custom property) then yes, you will need to make sure that the result set that comes back from the SPROC matches the schema mapped. If you are going to have variable field names coming back, then you could take this into the equation by creating a custom property (or multiple) which takes this logic into account.



3.) Let's talk Browse! How would I go about customizing the Browse dialog to allow for searching based on columns not mapped in the BOM? This question will, of course, lead to discussions about the new OverrideSearchTableName/Schema, which I will look at. That may or may not be the solution, depending on whether--for my purposes--I can setup a view (or, I guess, views and programmatically change the Override.... properties just before calling the BD.showDialog()) that handles all possible searches the users will want to construct. If it does, great. If not, I'm hoping the flexibility of calling a stored procedure from the BD is feasible.




You can get pretty crazy with the overriding logic now days on the BrowseDialog...but before going crazy here, might I first suggest just creating a view and then changing the OverRideSearchTableName...this will be the least complicated road to travel.
By Alex Luyando - 6/3/2009

Thanks Trent. I'll see how far this takes me.

________________

_____/ Regards,

____/ al
By Trent L. Taylor - 6/3/2009

Sounds good Smile
By Alex Luyando - 6/3/2009

LOL After going back to my code it looks like I ended up using the FillDataTable( ) method anyway. So, goes to show you that even a blind squirrel can get a nut every once in a while.



Thanks.
By Trent L. Taylor - 6/3/2009

LOL...I don't think your giving yourself enough credit! But I know where you are coming from...been there a number of times myself...TODAY! BigGrin