﻿<?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 » Business Objects and Data Access (How do I?)  » multi-table BO question</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 04:14:55 GMT</lastBuildDate><ttl>20</ttl><item><title>multi-table BO question</title><link>http://forum.strataframe.net/FindPost26226.aspx</link><description>Since I need to have a view to map my business objects to when pulling data from many tables, what (if any) is the advantage of populating via a SPROC versus using the view I already have defined for mapping?&lt;P&gt;I like (in theory) not having to keep the SPROC and views in sync. In admittedly limited testing performance seems equal.&lt;/P&gt;&lt;P&gt;Thanks in advance for your opinions, as always.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT size=3&gt;Method A (mapped to view, populate via SPROC, passing in parameters):&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;[quote]&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Public&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Sub&lt;/FONT&gt;&lt;/FONT&gt; FillBySprocGetRosterValues(&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;ByVal&lt;/FONT&gt;&lt;/FONT&gt; p_rosterPK &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;As&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Integer&lt;/FONT&gt;&lt;/FONT&gt;)&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt; cmd &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;As&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;New&lt;/FONT&gt;&lt;/FONT&gt; SqlCommand()&lt;/P&gt;&lt;P&gt;cmd.CommandType = CommandType.StoredProcedure&lt;/P&gt;&lt;P&gt;cmd.CommandText = &lt;FONT color=#a31515&gt;&lt;FONT color=#a31515&gt;"dbo.sdsi_GetRosterValues"&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;P&gt;&lt;FONT color=#008000&gt;&lt;FONT color=#008000&gt;'-- Create the parms&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;P&gt;cmd.Parameters.AddWithValue(&lt;FONT color=#a31515&gt;&lt;FONT color=#a31515&gt;"@rosterPK"&lt;/FONT&gt;&lt;/FONT&gt;, p_rosterPK).SqlDbType = SqlDbType.Int&lt;/P&gt;&lt;P&gt;&lt;FONT color=#008000&gt;&lt;FONT color=#008000&gt;'-- Return the results&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;P&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Me&lt;/FONT&gt;&lt;/FONT&gt;.FillDataTable(cmd)&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;End&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Sub&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;/FONT&gt;[/quote]&lt;P&gt;&amp;nbsp;&lt;STRONG&gt;&lt;FONT size=3&gt;Method 2 (Map to view, populate BO using the&amp;nbsp;view):&lt;/FONT&gt;&lt;/STRONG&gt;&lt;P&gt;[quote]&lt;P&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Public&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Sub&lt;/FONT&gt;&lt;/FONT&gt; FillBySessionPK(&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;ByVal&lt;/FONT&gt;&lt;/FONT&gt; p_sessionPK &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;As&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Integer&lt;/FONT&gt;&lt;/FONT&gt;)&lt;/P&gt;&lt;P&gt;&lt;FONT color=#008000&gt;&lt;FONT color=#008000&gt;'-- Establish locals&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;P&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt; loCommand &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;As&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;New&lt;/FONT&gt;&lt;/FONT&gt; SqlCommand()&lt;/P&gt;&lt;P&gt;&lt;FONT color=#008000&gt;&lt;FONT color=#008000&gt;'-- Build the query&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;P&gt;loCommand.CommandText = &lt;FONT color=#a31515&gt;&lt;FONT color=#a31515&gt;"SELECT * FROM vwAllAcademiesBySession WHERE sxa_session_fk = @param1"&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;P&gt;&lt;FONT color=#008000&gt;&lt;FONT color=#008000&gt;'-- Add the parameter&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;P&gt;loCommand.Parameters.Add(&lt;FONT color=#a31515&gt;&lt;FONT color=#a31515&gt;"@param1"&lt;/FONT&gt;&lt;/FONT&gt;, SqlDbType.Int)&lt;/P&gt;&lt;P&gt;loCommand.Parameters(&lt;FONT color=#a31515&gt;&lt;FONT color=#a31515&gt;"@param1"&lt;/FONT&gt;&lt;/FONT&gt;).Value = p_sessionPK&lt;/P&gt;&lt;P&gt;&lt;FONT color=#008000&gt;&lt;FONT color=#008000&gt;'-- Execute the command to fill the business object&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;P&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Me&lt;/FONT&gt;&lt;/FONT&gt;.FillDataTable(loCommand)&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;End&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Sub&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;/FONT&gt;[/quote]</description><pubDate>Mon, 01 Mar 2010 08:54:18 GMT</pubDate><dc:creator>Keith Chisarik</dc:creator></item><item><title>RE: multi-table BO question</title><link>http://forum.strataframe.net/FindPost26246.aspx</link><description>Sorry I missed this post, Keith.&lt;br&gt;
&lt;br&gt;
Well, in short, speed.  There can be other advantages and disadvantages of either as well depending on your circumstances.  Recently, like all last week, we spent a lot of time tweaking queries on one of our online servers that calculates insurance formulary results for a patient when retrieving drug results in our prescription writer.  This database is so massive and changes daily that we actually keep this on central online servers and query through web services.  Not only that, we may query millions of records, across dozens of tables, etc.  Through this process, we had some views that were part of some of these embedded queries that were killing us (keep in mind that 500 ms [half a second] would be an extremely long query time here).  We tried indexed views, but still, no joy.  So be back off, made direct table queries with properly placed indexes after living in the Execution Plans for a while.&lt;br&gt;
&lt;br&gt;
The Execution Plan plays a big part here as well in regards to how well a view may perform (not to mention the number of records).  When all was said an done, the query went from 400 ms down to 12 ms.  This is a MAJOR improvement and when you are talking about recursive queries and a large number of transactions, this makes a big difference.&lt;br&gt;
&lt;br&gt;
Don't get me wrong, we still use views and they are super handy.  But if you are in a situation where performance is a must and you are dealing with large numbers of records, then a view [u]may[/u] slow things down....not always...but it is always something I keep an eye on.&lt;br&gt;
&lt;br&gt;
In short, there is nothing wrong with either approach if you are getting the performance and results that you are looking for. :)</description><pubDate>Mon, 01 Mar 2010 08:54:18 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>