﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WinForms (How do I?)  » Mapping a BO to a Stored Procedure...</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 07:02:36 GMT</lastBuildDate><ttl>20</ttl><item><title>Mapping a BO to a Stored Procedure...</title><link>http://forum.strataframe.net/FindPost1119.aspx</link><description>I want to fill a listview using a stored procedure.  I like the simplicity of the business object method, however I'm not sure you can base a BO on a stored procedure. I have it working...kind of.  I created a view that is identical to the stored procedure so that I can create a BO based on the view and then I call the stored procedure in the fill method of the BO class.  Am I able to base a business object on a stored procedure or could you suggest a better way? I don't necessarily want to create a view for every stored procedure that I want to base a BO on.&lt;br&gt;
&lt;br&gt;
Thanks</description><pubDate>Mon, 08 May 2006 16:04:42 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: Mapping a BO to a Stored Procedure...</title><link>http://forum.strataframe.net/FindPost1134.aspx</link><description>No, that's really considered the best practice since it's the dynamic way of doing it.&amp;nbsp; It becomes a maintenance nightmare if you have to create a new view for each stored procedure...</description><pubDate>Mon, 08 May 2006 16:04:42 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Mapping a BO to a Stored Procedure...</title><link>http://forum.strataframe.net/FindPost1132.aspx</link><description>So then, theoretically I could use one BO and fill one or more listviews using one or more stored procedures by piggybacking off that BO.&lt;br&gt;
&lt;br&gt;
Is that considered best practices or would you suggest a better way to fill listviews based on stored procedures?</description><pubDate>Mon, 08 May 2006 14:22:10 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: Mapping a BO to a Stored Procedure...</title><link>http://forum.strataframe.net/FindPost1129.aspx</link><description>The piggy backing won't affect the operation of the business object... when the ListView builds the list, it uses the "Item" property on the business object to pull the data from the business object by field name.&amp;nbsp; The item property goes through this methodology:&lt;P&gt;1.&amp;nbsp; Search for the fieldname in the existing PropertyDescriptors collection.&amp;nbsp; If found, return the value.&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; Search for the fieldname by reflecting the business object for the property name.&amp;nbsp; If found, add a property descriptor, then return the value.&lt;/P&gt;&lt;P&gt;3.&amp;nbsp; Search for the fieldname within the columns of the internal data table.&amp;nbsp; If found, add a property descriptor, then return the value.&lt;/P&gt;&lt;P&gt;So, the only thing you're going to have is a few extra property descriptors in your PropertyDescriptors collection (which isn't a bad thing).&amp;nbsp; And as you can see, once a field is found, the location of the data for that field name is cached, so the Item property doesn't have to go searching for it again.&amp;nbsp; So, you have a couple microsecond delay when you reference the column the first time, but after that, it's just as fast as anything else.&lt;/P&gt;&lt;P&gt;This functionality was added mainly because when we build ListViews, we invariably end up adding extra columns to the return data for display purposes; generally the results of aggregate functions in SQL Server.&amp;nbsp; I.e.: we create a list of the customers in the database, and add a cust_count field that counts the users by last name (COUNT(cust_lname) AS cust_count).&amp;nbsp; When we do this, we can manually type in cust_count and don't have to create a view or remap the business object.</description><pubDate>Mon, 08 May 2006 09:20:23 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Mapping a BO to a Stored Procedure...</title><link>http://forum.strataframe.net/FindPost1128.aspx</link><description>So you're saying... create a method in the BO that executes the stored procedure I want to gather data from. Then, in the PopulationDataSourceSettings choose the BO that contains the method and choose the method to execute from the drop down.  Then in the fields to display drop down i can manually type in the names of the fields and it will pull them from the table.  Is that right?&lt;br&gt;
&lt;br&gt;
If I understand what you're telling me then I can just piggy back off any other BO to get the job done.  How does this piggy back affect the normal operation of the BO.  &lt;br&gt;
&lt;br&gt;
This is what the Data Retrieval region will look like in the BO.&lt;br&gt;
&lt;br&gt;
[code]&lt;br&gt;
Public Sub Fill()&lt;br&gt;
     Me.FillDataTable("SELECT * FROM Customers")&lt;br&gt;
End Sub&lt;br&gt;
&lt;br&gt;
Public Sub FillOrdersByCustomerID(ByVal CustomerID as Integer)&lt;br&gt;
        '--Establish locals&lt;br&gt;
        Dim loCmd As New SqlCommand()&lt;br&gt;
&lt;br&gt;
        '--Build the query&lt;br&gt;
        loCmd.CommandText = "uspGetOrdersByCustomerID"&lt;br&gt;
        loCmd.CommandType = CommandType.StoredProcedure&lt;br&gt;
&lt;br&gt;
        '--Add the parameter&lt;br&gt;
        loCmd.Parameters.Add("@CustomerID", SqlDbType.Int)&lt;br&gt;
        loCmd.Parameters("@CustomerID").Value = CustomerID&lt;br&gt;
&lt;br&gt;
        '--Execute the command to fill the business object&lt;br&gt;
        Me.FillDataTable(loCmd)&lt;br&gt;
End Sub&lt;br&gt;
[/code]&lt;br&gt;
&lt;br&gt;
Is the FillOrdersByCustomerID going to affect the other Fill method? They are both using the same method... FillDataTable.&lt;br&gt;</description><pubDate>Mon, 08 May 2006 09:07:20 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: Mapping a BO to a Stored Procedure...</title><link>http://forum.strataframe.net/FindPost1127.aspx</link><description>We are planning to eventually allow you to build a business object off of a stored procedure, but at the moment, we don't have that functionality.</description><pubDate>Mon, 08 May 2006 08:50:17 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Mapping a BO to a Stored Procedure...</title><link>http://forum.strataframe.net/FindPost1126.aspx</link><description>If you are using the results of the stored procedure to create the list view, you can actually use any business object you want to.&amp;nbsp; Here's how it works.&amp;nbsp; When you set the PopulationDataSourceSettings for the list view, you'll notice that when adding a new Display Field, you have the drop down list of the available fields, however in that drop down list, you can type anything you need into the blank.&amp;nbsp; So, you can use any business object, regarless whether is has the same structure as the stored procedure results, and manually type in the Display Fields.&amp;nbsp; When the list builds, the list will determine that the fields do not belong on the business object, and will pull them from the internal DataTable (even though the properties don't exist).&amp;nbsp; So, you can build ListViews all day long without a business object that matches the structure, however, if you want to work with the results of the stored procedure in code (unlikely, since you cannot save your changes to it), you won't have the strong typed properties to work with.&lt;/P&gt;&lt;P&gt;Hopefully that makes sense :)</description><pubDate>Mon, 08 May 2006 08:49:35 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item></channel></rss>