<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:blogChannel="http://backend.userland.com/blogChannelModule" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
  <channel>
    <title>Orasis Software Blog</title>
    <description />
    <link>http://www.orasissoftware.com/Blog/</link>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <generator>BlogEngine.NET 1.5.0.7</generator>
    <language>en-GB</language>
    <blogChannel:blogRoll>http://www.orasissoftware.com/Blog/opml.axd</blogChannel:blogRoll>
    <blogChannel:blink>http://www.orasissoftware.com/blog/syndication.axd</blogChannel:blink>
    <dc:creator>My name</dc:creator>
    <dc:title>Orasis Software Blog</dc:title>
    <geo:lat>0.000000</geo:lat>
    <geo:long>0.000000</geo:long>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/TheOrasisSoftwareBlog" /><feedburner:info uri="theorasissoftwareblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
      <title>Orasis Mapping Studio eliminates NHibernate performance problems</title>
      <description>&lt;p&gt;Writing SQL queries is something NHibernate eliminates for the developers when writing data access code. Complex data models and Hibernate (HQL) queries can often lead to slow performing generated SQL resulting in overall database access performance problems. Also, if the volume of data returned is large, the reflection operations which load data into the objects can add performance lag during data loading compared to instantiating objects using the new statement and assigning data to properties natively in C#.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.orasissoftware.com/products.aspx?topic=orasismappingstudiobenefits"&gt;Orasis Mapping Studio&lt;/a&gt; uses SQL to build your data access and can map the queries directly to the same Domain objects that NHibernate maps to. To eliminate the performance problems, we can take the NHibernate queries, capture the SQL, and optimize them to a pure ADO.NET method returning a list of NHibernate Domain objects. All this can be done through the Orasis Mapping Studio.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Capturing the SQL&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You can capture the generated SQL in the NHibernate generated log when using the&lt;/p&gt;  &lt;pre class="code"&gt;&amp;lt;property name=&lt;span style="color: #a31515"&gt;&amp;quot;show_sql&amp;quot;&lt;/span&gt;&amp;gt;&lt;span style="color: blue"&gt;true&lt;/span&gt;&amp;lt;/property&amp;gt;&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;configuration element in the NHibernate config file, either through the console or log file when running the application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Optimizing the Query&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once you have captured the SQL, launch the Orasis Mapping Studio and open or create a mapping project connecting to your database. Then launch the Query Designer through the Tools, Query Designer menu.&lt;/p&gt;

&lt;p&gt;Paste the query into the query designer and let it parse it. You will be able to see your query visually now and execute it with the parameters it may have to see its execution time. You can then optimize the query by minimizing sub queries and writing efficient joins.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Map to the existing NHibernate Domain Object&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once you are satisfied with the query, click the Create mapping button. This will walk you through mapping your query to the object that you want it mapped to. In the third page of the wizard, where the Type Selector appears, select the Import type tab and select the Assembly in which your Domain objects are and then select the Domain object to map to. For a more in depth walk through of creating mappings read here: &lt;a href="http://www.orasissoftware.com/blog/post/2009/03/28/Smart-Code-Generation-for-Data-Access-Using-Orasis-Mapping-Studio.aspx"&gt;http://www.orasissoftware.com/blog/post/2009/03/28/Smart-Code-Generation-for-Data-Access-Using-Orasis-Mapping-Studio.aspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the mapping is complete and the project is built you will now have a generated method built with pure ADO.NET to execute the query and return you the Domain objects in a list, with the parameters necessary to execute the query. The method will be generated with very efficient ADO.NET code to execute your query and load your objects.&lt;/p&gt;

&lt;p&gt;Your Data Access Code will now perform much faster, the SQL will be well tested and the NHibernate domain object that you have built your application will be reused. It will be all manageable through the Orasis Mapping Studio project file for future modifications to your query, object and mappings.&lt;/p&gt;</description>
      <link>http://feedproxy.google.com/~r/TheOrasisSoftwareBlog/~3/iW82FzTj2yM/post.aspx</link>
      <author>adnan</author>
      <comments>http://www.orasissoftware.com/Blog/post/2009/05/05/Orasis-Mapping-Studio-eliminates-NHibernate-performance-problems.aspx#comment</comments>
      <guid isPermaLink="false">http://www.orasissoftware.com/Blog/post.aspx?id=7dc3aaca-942b-4764-b965-0c1da654abe2</guid>
      <pubDate>Tue, 05 May 2009 07:13:00 -1100</pubDate>
      <dc:publisher>adnan</dc:publisher>
      <pingback:server>http://www.orasissoftware.com/Blog/pingback.axd</pingback:server>
      <pingback:target>http://www.orasissoftware.com/Blog/post.aspx?id=7dc3aaca-942b-4764-b965-0c1da654abe2</pingback:target>
      <slash:comments>233</slash:comments>
      <trackback:ping>http://www.orasissoftware.com/Blog/trackback.axd?id=7dc3aaca-942b-4764-b965-0c1da654abe2</trackback:ping>
      <wfw:comment>http://www.orasissoftware.com/Blog/post/2009/05/05/Orasis-Mapping-Studio-eliminates-NHibernate-performance-problems.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.orasissoftware.com/Blog/syndication.axd?post=7dc3aaca-942b-4764-b965-0c1da654abe2</wfw:commentRss>
    <feedburner:origLink>http://www.orasissoftware.com/Blog/post.aspx?id=7dc3aaca-942b-4764-b965-0c1da654abe2</feedburner:origLink></item>
    <item>
      <title>Comparison of Linq to Sql and Orasis Generated Data Access Code</title>
      <description>&lt;p&gt;Lets look at a brief code by code comparison of how to perform different data access operations using the Linq to Sql framework compared to using the Orasis Generated data access layer from a mapping project.  &lt;p&gt;Download the NorthwindDataAccess project file and open it with the &lt;a href="http://www.orasissoftware.com/download.aspx"&gt;Orasis Mapping Studio&lt;/a&gt;. Edit the database connection string by right clicking on the Database node and changing the connection properties to point to your Northwind database. &lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;div class="wlWriterSmartContent" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:d1901127-f26e-4bb3-860d-0d4642c37ff9" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt; &lt;p&gt;Northwind Mapping Project &lt;a href="http://www.orasissoftware.com/blog/file.axd?file=Northwind_10.xmp" target="_blank"&gt;File&lt;/a&gt;&lt;/p&gt;&lt;/div&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;The Linq to SQL Context is setup by Connecting to the Northwind database and adding the Product table to the dbml designer in Visual Studio. We will name our context NorthwindDataContext.&lt;/p&gt; &lt;p&gt;Let us see some examples of data access operations for the Products table from Linq to Sql and from the Data Access Code generated by the Orasis Mapping Studio.  &lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;strong&gt;Selecting a Product from the Northwind Database&lt;/strong&gt;:  &lt;p&gt;Linq to SQL: (C#)&lt;pre&gt;NorthwindDataContext nwContext = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; NorthwindDataContext(); 
var products = &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=from&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;from&lt;/a&gt; p &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=in&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;in&lt;/a&gt; db.Products &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=where&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;where&lt;/a&gt; p.ProductId = 1
               &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=select&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;select&lt;/a&gt; p; 
&lt;/pre&gt;
&lt;p&gt;&amp;nbsp; &lt;p&gt;Orasis Generated Data Access Layer:&lt;pre&gt;NorthwindDataAccess nwDal = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; NorthwindDataAccess(); 
IList&amp;lt;Product&amp;gt; productsList = nwDal.GetProductbyId(1);
&lt;/pre&gt;
&lt;p&gt;The SQL query in the GetProductbyID mapping is :&lt;pre&gt;&lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=Select&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;Select&lt;/a&gt; * &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=From&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;From&lt;/a&gt; Products
	&lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=Where&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;Where&lt;/a&gt; Products.ProductID = @productId&lt;/pre&gt;
&lt;p&gt;The query was written and mapped to the Product object using the Mapping Studio’s mapping wizard. 
&lt;p&gt;The result is strongly typed, and the parameters are clearly defined. Also, the caller of the Data Access Library does not need to see the query, he just calls the method which gets him the Objects. 
&lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;strong&gt;Updating a Product:&lt;/strong&gt; 
&lt;p&gt;The code below shows both approaches of how to retrieve a product by its ID and update its Name and Unit Price. 
&lt;p&gt;Linq to SQL: (C#);&lt;pre&gt;NorthwindDataContext nwContext = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; NorthwindDataContext ();
Product product = nwContext.Products.Single(p =&amp;gt; p.ProductId == 1);

product.ProductName = "&lt;span style="color: #8b0000"&gt;New Name&lt;/span&gt;";
product.UnitPrice = 23;

nwContext.SubmitChanges();
&lt;/pre&gt;
&lt;p&gt;Orasis Generated Data Access Layer:&lt;/p&gt;&lt;pre&gt;NorthwindDataAccess nwDal = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; NorthwindDataAccess(); 
Product product = nwDal.GetProductbyId(1)[0]; 

product.Name = "&lt;span style="color: #8b0000"&gt;New Name&lt;/span&gt;"; 
product.UnitPrice = 23; 

int rowsAffected = nwDal.UpdateProducts(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;Product&amp;gt;{ product });&lt;/pre&gt;
&lt;p&gt;&lt;br&gt;The query inside the UpdateProducts method is:&lt;/p&gt;&lt;pre&gt;&lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=Update&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;Update&lt;/a&gt; dbo.Products &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=set&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;set&lt;/a&gt; ProductName = @ProductName,
UnitPrice = @UnitPrice
&lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=where&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;where&lt;/a&gt; ProductID = @ProductId&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Inserting a Product&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Linq to SQL: (C#)&lt;/p&gt;&lt;pre&gt;NorthwindDataContext nwContext = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; NorthwindDataContext (); 

Product product1 = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Product();
product1.ProductName = "&lt;span style="color: #8b0000"&gt;New Product1&lt;/span&gt;";
product1.UnitPrice = 35;&lt;br&gt;product.Category = 1; &lt;/pre&gt;&lt;pre&gt;nwContext.Products.Add(product1);
nwContext.SubmitChanges();
&lt;/pre&gt;
&lt;p&gt;&amp;nbsp; &lt;p&gt;Orasis Generated Data Access Layer:&lt;pre&gt;NorthwindDataAccess nwDal = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; NorthwindDataAccess(); 

Product product = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Product(); 
product.ProductName = "&lt;span style="color: #8b0000"&gt;New Product&lt;/span&gt;";
product.UnitPrice = 23; 
product.Category = 1;

&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; rowsAffected = nwDal.InsertProducts(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;Product&amp;gt;{ product });
&lt;/pre&gt;
&lt;p&gt;The insert Query inside the mapping is :&lt;/p&gt;&lt;pre&gt;&lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=Insert&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;Insert&lt;/a&gt; &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=into&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;into&lt;/a&gt; dbo.Products(ProductName,UnitPrice,CategoryID) &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=values&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;values&lt;/a&gt; (@ProductName,@UnitPrice,@CategoryID)&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Deleting a Product:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In the code below we will delete a product with the name “New Product”.&lt;/p&gt;
&lt;p&gt;Linq to SQL: (C#)&lt;/p&gt;&lt;pre&gt;NorthwindDataContext nwContext = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; NorthwindDataContext ();&lt;/pre&gt;&lt;pre&gt;Product productToDelete = nwContext.Products.Single(p =&amp;gt; p.ProductName == "&lt;span style="color: #8b0000"&gt;New Product&lt;/span&gt;");
nwContext.Products.DeleteOnSubmit(productToDelete );                &lt;/pre&gt;&lt;pre&gt;nwContext.SubmitChanges();&lt;/pre&gt;&lt;pre&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Calling the Orasis Generated Data Access Layer:&lt;/p&gt;&lt;pre&gt;NorthwindDataAccess nwDal = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; NorthwindDataAccess(); 

Product product = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Product(); 
product.ProductName = "&lt;span style="color: #8b0000"&gt;New Product&lt;/span&gt;"; 

&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; rowsAffected = nwDal.DeleteProductByName(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;Product&amp;gt;{ product }); &lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The Query inside the DeleteProductByName Mapping is :&lt;/p&gt;&lt;pre&gt;&lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=Delete&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;Delete&lt;/a&gt; &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=from&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;from&lt;/a&gt; dbo.Products &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=where&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;where&lt;/a&gt; Products.ProductName = @ProductName&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Calling a Stored Procedure&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The code below demonstrates calling a stored procedure that we created in the Database to return products by Category called ‘GetProductsByCategory’.&lt;/p&gt;
&lt;p&gt;Linq to SQL: (C#)&lt;/p&gt;&lt;pre&gt;NorthwindDataContext nwContext = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; NorthwindDataContext ();

var products = nwContext.GetProductsByCategory(1);

&lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (Product product &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; products)
{
	System.Console.WriteLine("&lt;span style="color: #8b0000"&gt;Product Name:&lt;/span&gt;" + product.ProductName);
}&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Orasis Generated Data Access Layer with a Mapping to the same Stored Procedure:&lt;/p&gt;&lt;pre&gt;NorthwindDataAccess nwDal = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; NorthwindDataAccess(); 

IList&amp;lt;Product&amp;gt; products = mdDal.GetProductsByCategory(1);&lt;/pre&gt;&lt;pre&gt;&lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (Product product &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; products) 
{ 
	System.Console.WriteLine("&lt;span style="color: #8b0000"&gt;Product Name:&lt;/span&gt;" + product.ProductName); 
}
&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This concludes our side by side code comparison of accessing our Northwind database through Linq to SQL, compared to Mapping the Database through the Orasis Mapping Studio’s mappings. The end results are same for accessing the database through Objects.&lt;/p&gt;</description>
      <link>http://feedproxy.google.com/~r/TheOrasisSoftwareBlog/~3/T5cmGSf7HFo/post.aspx</link>
      <author>adnan</author>
      <comments>http://www.orasissoftware.com/Blog/post/2009/04/26/Comparison-of-Linq-to-Sql-and-Orasis-Generated-Data-Access-Code.aspx#comment</comments>
      <guid isPermaLink="false">http://www.orasissoftware.com/Blog/post.aspx?id=18ae81d0-ef88-444e-b302-6c9aabe984bc</guid>
      <pubDate>Sun, 26 Apr 2009 09:19:18 -1100</pubDate>
      <dc:publisher>adnan</dc:publisher>
      <pingback:server>http://www.orasissoftware.com/Blog/pingback.axd</pingback:server>
      <pingback:target>http://www.orasissoftware.com/Blog/post.aspx?id=18ae81d0-ef88-444e-b302-6c9aabe984bc</pingback:target>
      <slash:comments>195</slash:comments>
      <trackback:ping>http://www.orasissoftware.com/Blog/trackback.axd?id=18ae81d0-ef88-444e-b302-6c9aabe984bc</trackback:ping>
      <wfw:comment>http://www.orasissoftware.com/Blog/post/2009/04/26/Comparison-of-Linq-to-Sql-and-Orasis-Generated-Data-Access-Code.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.orasissoftware.com/Blog/syndication.axd?post=18ae81d0-ef88-444e-b302-6c9aabe984bc</wfw:commentRss>
    <feedburner:origLink>http://www.orasissoftware.com/Blog/post.aspx?id=18ae81d0-ef88-444e-b302-6c9aabe984bc</feedburner:origLink></item>
    <item>
      <title>SQL Based O/R Mapping?</title>
      <description>&lt;p&gt;After reviewing all the major ORM technologies out there and participating in a project that was a classic ORM nightmare, I have come to the following conclusion: ORM is a good acronym but not a good concept. But, I must give credit where credit is due; ORMs have moved us forward in thinking of Objects and making our applications more Object Oriented. Gone are the days when binding a grid to a DataTable or some other data structure directly from the data provider was considered a viable solution.    &lt;br /&gt;    &lt;br /&gt;Here is the bad part about ORMs, and we must learn from the negatives to come up with a positive solution. They couple or glue your Objects to your Database Schema in some form, directly or indirectly. How about if we mapped SQL Results to Objects instead of mapping relational schemas to Objects? One couples your Relational Schema to your Objects while the other maps to SQL which is the natural language of any Relational Database. In this way the abstraction is at a higher level and not at the database's schema level.     &lt;br /&gt;    &lt;br /&gt;The reason why ORMs are problematic is that they introduce their own query languages that query your Objects instead of tables. They say they hide the &amp;quot;complexity&amp;quot; of SQL, but in reality it's the only way you can get objects out of an ORM. It's a simple fact that Objects are not designed to be queried. They are not inherently relational structures, they are hierarchical. Database Tables, views, etc are all relational tuples designed for storage and queries. So which one would you query against?     &lt;br /&gt;    &lt;br /&gt;Aside from the query, ORMs let you map data directly into objects without having to write mapping code. That is a great convenience, I admit. In the process they take care of type conversions, null checks, nullable types, data lengths, etc. all which are quite painful to write for developers. Now remember, that you do take a performance hit because ORMs use reflection to do this work for you which is slower than native object instantiation and population, but for most cases it is negligible.     &lt;br /&gt;    &lt;br /&gt;So the lesson learnt is that if SQL queries were brought back into the picture and somehow the mapping of results, and parameters from the Query to the Objects was automated and managed and the Objects were allowed to be decoupled from the Database that would be a better solution than an ORM.     &lt;br /&gt;    &lt;br /&gt;The only problem is that you would need a tool to manage all this work and possibly generate the code for mapping each query to an Object.     &lt;br /&gt;    &lt;br /&gt;So why not try a SQL to Object mapping solution? It seems, at least to me, to be a more viable solution than using an ORM solution. I'm sure many of you may have already tried this. Let me know your degree of success if you did.&lt;/p&gt;  &lt;p&gt;You can also try the Orasis Mapping Studio which was built from the ground up to do SQL based O/R Mapping at &lt;a href="http://www.orasissoftware.com/download.aspx"&gt;http://www.orasissoftware.com/download.aspx&lt;/a&gt;&lt;/p&gt;</description>
      <link>http://feedproxy.google.com/~r/TheOrasisSoftwareBlog/~3/o23z_zm2e5Y/post.aspx</link>
      <author>adnan</author>
      <comments>http://www.orasissoftware.com/Blog/post/2009/04/11/SQL-Based-OR-Mapping.aspx#comment</comments>
      <guid isPermaLink="false">http://www.orasissoftware.com/Blog/post.aspx?id=5bbf7036-8b69-4b3b-97cd-62171fc0c2db</guid>
      <pubDate>Sat, 11 Apr 2009 05:04:47 -1100</pubDate>
      <dc:publisher>adnan</dc:publisher>
      <pingback:server>http://www.orasissoftware.com/Blog/pingback.axd</pingback:server>
      <pingback:target>http://www.orasissoftware.com/Blog/post.aspx?id=5bbf7036-8b69-4b3b-97cd-62171fc0c2db</pingback:target>
      <slash:comments>100</slash:comments>
      <trackback:ping>http://www.orasissoftware.com/Blog/trackback.axd?id=5bbf7036-8b69-4b3b-97cd-62171fc0c2db</trackback:ping>
      <wfw:comment>http://www.orasissoftware.com/Blog/post/2009/04/11/SQL-Based-OR-Mapping.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.orasissoftware.com/Blog/syndication.axd?post=5bbf7036-8b69-4b3b-97cd-62171fc0c2db</wfw:commentRss>
    <feedburner:origLink>http://www.orasissoftware.com/Blog/post.aspx?id=5bbf7036-8b69-4b3b-97cd-62171fc0c2db</feedburner:origLink></item>
    <item>
      <title>ADO.Net is back</title>
      <description>&lt;h3&gt;ADO.Net revived. Why now visual crafting of your data access tier seems the right solution. Start mapping not coding!&lt;/h3&gt; &lt;/p&gt; &lt;h4&gt;Craft your database access API visually.&lt;/h4&gt;  &lt;p&gt;Visual creation of your database access tier seems more attractive than ever today. Simply drag, drop, click to auto generate your database access tier. Test your actual data access code without writing either the data access code or the tests. Orasis Mapping Studio 2009 makes it all possible.&lt;/p&gt;  &lt;h4&gt;Utilize the power of ADO.Net but do not write it.&lt;/h4&gt;  &lt;p&gt;Writing ADO.Net code can be a tedious job but given the right tool to auto generate it makes it a comeback. The hassle of writing ADO.Net and creating queries by hand is nullified with one comprehensive solution.&lt;/p&gt;  &lt;h4&gt;Use an ORM but not with the drawbacks.&lt;/h4&gt;  &lt;p&gt;Yes an ORM solution has a lot of drawbacks. It is time to face reality. Orasis allows you to ORM but in a more easy way. Visually map your queries to your object graphs. Simple as this.&lt;/p&gt;  &lt;h4&gt;Object Query languages; LINQ-SQL, HQL Are they easy to use?&lt;/h4&gt;  &lt;p&gt;ORM implementations of different flavors that introduce object query languages and auto generation of not so optimized SQL underneath the hood can cause development time delays and substantial performance issues. This is a proven fact and developers are starting to realize that maybe they should be looking somewhere else. Data access plays a vital role in business applications; and performance is one of the key factors to consider in any data-intensive application. There are many factors that can affect data-access performance negatively, such as network load, load on the database server, un-optimized SQL, and so on. Apart from these, there are other factors to consider with respect to the various data-access operations that most applications perform, such as opening and closing a connection, fetching a result set, blob access, and metadata retrieval, utilization of reflection/introspection, need for distributed object caching, etc. First of all, I have never seen a real enterprise system that involves fair amount of database access going into production without optimization. During regression testing, different operations show their true colors especially under load. That is when engineering teams jump in and try to optimize SQL and data access code. If the code was written by utilizing some object query language, the question remains on how you optimize performance since the SQL is generated dynamically by the ORM engine. &lt;/p&gt;  &lt;h4&gt;ORMs always perform faster? &lt;/h4&gt;  &lt;p&gt;Some developers support that ORMs perform faster even though:&lt;/p&gt;  &lt;p&gt;ADO.Net is the most direct access to the database.&lt;/p&gt;  &lt;p&gt;ORMs usually need an Object cache to offer compatible performance.&lt;/p&gt;  &lt;p&gt;Ignore the fact that reflection/introspection versus direct access of model object properties is very expensive.&lt;/p&gt;  &lt;h4&gt;The illusion of avoiding SQL.&lt;/h4&gt;  &lt;p&gt;So why is this happening? It seems that the fact that developers think they do not have to deal with SQL makes ORMs so attractive that all of the overheads associated with them simply vanish. The truth is that object query language constructs are not easy to understand and use either, so developers end up writing the query but in a different language. Looking at a fairly involved object query code snippet one realizes that the object API is not for the average developer. This is where ROI kicks in and on a large scale system the time simply adds up to a lot of money and frustration. A related article that explains the ROI can be accessed at &lt;a href="http://forums.orasissoftware.com/comments.php?DiscussionID=7&amp;amp;page=1#Item_0"&gt;http://forums.orasissoftware.com/comments.php?DiscussionID=7&amp;amp;page=1#Item_0&lt;/a&gt;&lt;/p&gt;  &lt;h4&gt;Classes to table Mappings. Is this what we want?&lt;/h4&gt;  &lt;p&gt;Even though most ORM implementations force a one to one mapping of database tables to Classes, it seems that not many people object this practice. So let me understand this; we are using an object query language to abstract us from the database but our model object match the database tables 100%?&lt;/p&gt;  &lt;p&gt;Since when my business object model should resemble my physical storage? Isn’t that a disadvantage? Should I waste time talking why is a bad practice? I guess not since it is a fact. &lt;/p&gt;</description>
      <link>http://feedproxy.google.com/~r/TheOrasisSoftwareBlog/~3/9MZZVmbfJ1Y/post.aspx</link>
      <author>neophytos</author>
      <comments>http://www.orasissoftware.com/Blog/post/2009/04/08/ADONet-is-back.aspx#comment</comments>
      <guid isPermaLink="false">http://www.orasissoftware.com/Blog/post.aspx?id=faab979c-2bf3-4205-b4f1-d9145d95a446</guid>
      <pubDate>Wed, 08 Apr 2009 17:14:21 -1100</pubDate>
      <dc:publisher>neophytos</dc:publisher>
      <pingback:server>http://www.orasissoftware.com/Blog/pingback.axd</pingback:server>
      <pingback:target>http://www.orasissoftware.com/Blog/post.aspx?id=faab979c-2bf3-4205-b4f1-d9145d95a446</pingback:target>
      <slash:comments>142</slash:comments>
      <trackback:ping>http://www.orasissoftware.com/Blog/trackback.axd?id=faab979c-2bf3-4205-b4f1-d9145d95a446</trackback:ping>
      <wfw:comment>http://www.orasissoftware.com/Blog/post/2009/04/08/ADONet-is-back.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.orasissoftware.com/Blog/syndication.axd?post=faab979c-2bf3-4205-b4f1-d9145d95a446</wfw:commentRss>
    <feedburner:origLink>http://www.orasissoftware.com/Blog/post.aspx?id=faab979c-2bf3-4205-b4f1-d9145d95a446</feedburner:origLink></item>
    <item>
      <title>How to Choose a Technology for your Data Access tier</title>
      <description>&lt;div class="CommentBody"&gt;
Should you choose an ORM implementation or simply allow a tool to craft your data services to your actual and immediate needs? Do you need both options in your projects? Can an ORM implementation satisfy the performance requirements, the ease of use and ease of changes? Can you really avoid SQL at no cost? Does an object query language make our lives easier or harder? Does any ORM implementation address the Object-Relational Impedance Mismatch?&lt;br /&gt;
&lt;br /&gt;
Choosing a technology for your database access layer seems to be a challenging decision for many projects today. There are many advocates of different ORM implementations and object query languages of some sort. Some claim one object query language is simpler than the other; some ORM implementations support all the major object query languages and some developers write their own abstraction layer to the object query language of the specific ORM implementation that they have chosen. &lt;br /&gt;
&lt;br /&gt;
To really benchmark an ORM implementation is extremely challenging since different schemas carry their own complexities and application requirements. In terms of tuning the queries, the choices appear to be quite limited with ORM implementations and require &amp;ldquo;expert knowledge&amp;rdquo; to do it right if it can be done at all. &lt;br /&gt;
Multiple times, the compromise of multiple fetches to generate in memory domain structures from multiple domain objects deprecates performance but at least it gets the data. In reality there is no one seemingly easy way to judge performance. &lt;br /&gt;
&lt;br /&gt;
We can compare an ORM&amp;rsquo;s performance against the equivalent SQL and may turn out that this test can be misleading. Some important performance optimizations (for example, the transaction-level cache) can actually reduce performance for the kind of very trivial benchmarks that people typically write. This is more a problem of the triviality of the benchmarks than anything else. Problems that affect ORM performance in nontrivial use cases may not even exist. The biggest problems really come from what we call the &amp;quot;problem of graph navigation&amp;quot;, where the pattern of data access used by an object-oriented application is a fundamentally inefficient way to access relational data. A lot of times the data required are not a one to one mapping of domain objects to tables; multiple columns from different tables can make up a model object. In that case an ORM implementation is relatively useless. 
&lt;/div&gt;
&lt;div class="CommentBody"&gt;
&lt;br /&gt;
How about if we have an integrated development studio that allows us to build our own data services layer, that would allow us to edit/modify/benchmark all of our database access layer in one place with no ORM engine code underneath but only clean vendor-independent code with a choice of different drivers? If a hand crafted auto code generated data services solution is available then this is something that can be considered?&lt;br /&gt;
&lt;br /&gt;
Sometimes the problem is sort of cultural. Some developers come to using ORMs because they are uncomfortable with SQL and relational databases. ORM architects state that this is the wrong reason to use an ORM. Being comfortable with relational databases and SQL are requirements for using an ORM. One of the major reasons that databases succeeded is the pure power of SQL. How about if we could harvest the power of SQL, ADO.Net , the OOP concept and bring them together in a powerful visual mapping studio that allows automatic generation of data services code based on the visual mappings between database columns and objects? Is that a compromise or an improvement? Some debate that objects to query syntax is very complicated and they prefer to deal directly with SQL. It is also a fact that database administrators can participate in the optimization of SQL if they had easy access to it. The concept of a Mapping is a one compilation unit that is composed of two sub units; one being the SQL statement and the other the model object that translates into a method in the data service class. If both of these units are edited by their own visual editors then tuning should be a breeze. Mappings are part of a project and the project compiles to a data access library. In this case the data tier grows based on the application requirements and the data services themselves can be distributed in different projects. The application services have a choice to link to the data tier libraries that they need. Simply reference the libraries and access your data. If we have a choice to custom create and fully control the data services in terms of maintenance and growth, modularity and abstraction, benchmarking and round trip engineering, in an IDE that finally focuses only on all of these requirements of the data tier, should we consider it? Even if we choose an ORM that is not custom, could we use this in addition to that?&lt;br /&gt;
&lt;br /&gt;
Orasis software introduces the custom IDE data services crafter, the Orasis Mapping Studio 2009 and it provides the choice to utilize the better of the two worlds. Relational databases and class hierarchies should not relate as the ORM implementation specifies but they should relate on what the business requirements are. True mapping of objects to SQL should address object graphs at any depth level. If an object graph has contained members of abstract classes and interfaces, the mapping process should allow implementation classes of these instances to be replaced. Even contained members that are instantiable classes should be allowed to be replaced by derived ones. Data architects and developers can now orchestrate the development of the data tier layer and guarantee performance. The benchmarking features of the IDE on the data services code and the SQL perform the ultimate test. The ability to drill into any mapping through a visual editor to modify/enhance it reveals a powerful feature that needs to be taken into serious consideration. No system goes into production before it is tuned. &lt;br /&gt;
&lt;br /&gt;
Can a traditional ORM technology that generates model objects that map one to one to a database schema satisfy all the needs for data access in a system? Or even a more enhanced approach of an ORM like Entity framework that still shares the majority of the features of a traditional ORM can satisfy all of the needs of a true isolated database tier that targets performance in the enterprise? &lt;br /&gt;
The flexibility to map easily database fields to object properties in object graphs, auto generate custom data services layer code with no introspection code and validating it&amp;#39;s performance without having to write tedious testing code for it, in now an option. 
&lt;/div&gt;
</description>
      <link>http://feedproxy.google.com/~r/TheOrasisSoftwareBlog/~3/XOJSKtQxZQg/post.aspx</link>
      <author>Adnan</author>
      <comments>http://www.orasissoftware.com/Blog/post/2009/04/07/How-to-Choose-a-Technology-for-your-Data-Access-tier.aspx#comment</comments>
      <guid isPermaLink="false">http://www.orasissoftware.com/Blog/post.aspx?id=cc05b4d0-74cb-4d2f-ad00-dcf834d67648</guid>
      <pubDate>Tue, 07 Apr 2009 07:40:00 -1100</pubDate>
      <dc:publisher>Adnan</dc:publisher>
      <pingback:server>http://www.orasissoftware.com/Blog/pingback.axd</pingback:server>
      <pingback:target>http://www.orasissoftware.com/Blog/post.aspx?id=cc05b4d0-74cb-4d2f-ad00-dcf834d67648</pingback:target>
      <slash:comments>96</slash:comments>
      <trackback:ping>http://www.orasissoftware.com/Blog/trackback.axd?id=cc05b4d0-74cb-4d2f-ad00-dcf834d67648</trackback:ping>
      <wfw:comment>http://www.orasissoftware.com/Blog/post/2009/04/07/How-to-Choose-a-Technology-for-your-Data-Access-tier.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.orasissoftware.com/Blog/syndication.axd?post=cc05b4d0-74cb-4d2f-ad00-dcf834d67648</wfw:commentRss>
    <feedburner:origLink>http://www.orasissoftware.com/Blog/post.aspx?id=cc05b4d0-74cb-4d2f-ad00-dcf834d67648</feedburner:origLink></item>
    <item>
      <title>Develop your data access layer using safe parameterized queries</title>
      <description>&lt;p&gt;One of the biggest concerns I face as a developer when writing SQL queries in my application is how to make them safe so that they are not prone to SQL injection attacks and at the same time they execute efficiently. Most developers go the route of putting all their queries as stored procedures in the database to handle the security and performance concern. Although this is a viable solution, it splits your application code in multiple places making it difficult to read, maintain and debug.&lt;/p&gt;  &lt;p&gt;Also I want to avoid writing the tedious ADO.NET code to create SQL Commands, add the parameters, set the right data types, check for nulls set nulls, etc. &lt;/p&gt;  &lt;p&gt;We can achieve all this with a high level of security, flexibility and maintainability by writing parameterized SQL queries and letting the Orasis Mapping Studio handle the mapping of parameters and generating data access code that executes the parameterized query and maps the results to our objects. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Parameterized Query&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;A parameterized query has SQL parameters embedded in the query itself, and the values of the parameters in the queries are set using the ADO.NET API to set parameters on the Command object. The parameterized query has a fixed execution plan therefore the database is able to cache the execution plan and it runs faster the next time the same query is executed. They are the safer, better, faster alternative to dynamic queries, that developers build by concatenating strings to the query to give it the dynamic effect.&lt;/p&gt;  &lt;p&gt;Example query:&lt;/p&gt;  &lt;pre&gt;&lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=select&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;select&lt;/a&gt; * &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=from&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;from&lt;/a&gt; users &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=where&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;where&lt;/a&gt; UserName = @userName &lt;/pre&gt;

&lt;pre&gt;&amp;#160;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Optional parameters&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Parameterized queries can also be written in such a way that allows certain parameters to be optional so that the database can ignore them if there is a null value provided for them. Here is an example of a parameterized query that has an optional parameter which will get ignored if there is a null value assigned to it. &lt;/p&gt;

&lt;pre&gt;&lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=select&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;select&lt;/a&gt; * &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=from&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;from&lt;/a&gt; users &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=where&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;where&lt;/a&gt; username = @username &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=and&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;and&lt;/a&gt; (usertype = @usertype &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=or&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;or&lt;/a&gt; @usertype &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=is&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;is&lt;/a&gt; &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=null&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;null&lt;/a&gt;)&lt;/pre&gt;

&lt;p&gt;The (usertype = @usertype &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=or&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;or&lt;/a&gt; @usertype &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=is&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;is&lt;/a&gt; &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=null&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;null&lt;/a&gt;) clause will resolve to ‘true’ if the @usertype parameter is set to null and therefore the query will in effect ignore the parameter.&lt;/p&gt;

&lt;p&gt;This query when mapped through the Orasis Mapping Studio will automatically have the parameters set to a null value if the user passes in null to the .NET method that gets generated.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Database Differences&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Different database use different delimiters for handling parameters such as ‘@’ for Microsoft SQL Server and Access, ‘:’ for Oracle,&amp;#160; and ‘@’ for MySql. The Orasis Mapping Studio is able to identify the right parameter for your database provider and parse the queries accordingly so that the code is generated accordingly and the values are set correctly.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s look at a sample query with parameters and map it to an object and see how the Orasis Mapping Studio generates code for the query. We will then run the query with different values and see the results we get. &lt;/p&gt;

&lt;p&gt;&lt;object width="640" height="480"&gt; &lt;param name="movie" value="http://content.screencast.com/users/AdnanOrasis/folders/Jing/media/9994446c-6aa7-43cf-8db6-12bdb188bf97/jingswfplayer.swf"&gt;&lt;/param&gt; &lt;param name="quality" value="high"&gt;&lt;/param&gt; &lt;param name="bgcolor" value="#FFFFFF"&gt;&lt;/param&gt; &lt;param name="flashVars" value="containerwidth=1916&amp;amp;containerheight=1195&amp;amp;loaderstyle=jing&amp;amp;content=http://content.screencast.com/users/AdnanOrasis/folders/Jing/media/9994446c-6aa7-43cf-8db6-12bdb188bf97/Orasis_Mapping_Studio_Parameterized_Query.swf"&gt;&lt;/param&gt; &lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt; &lt;param name="scale" value="showall"&gt;&lt;/param&gt; &lt;param name="allowScriptAccess" value="always"&gt;&lt;/param&gt; &lt;param name="base" value="http://content.screencast.com/users/AdnanOrasis/folders/Jing/media/9994446c-6aa7-43cf-8db6-12bdb188bf97/"&gt;&lt;/param&gt;  &lt;embed src="http://content.screencast.com/users/AdnanOrasis/folders/Jing/media/9994446c-6aa7-43cf-8db6-12bdb188bf97/jingswfplayer.swf" quality="high" bgcolor="#FFFFFF" width="640" height="480" type="application/x-shockwave-flash" allowScriptAccess="always" flashVars="containerwidth=640&amp;containerheight=480&amp;loaderstyle=jing&amp;content=http://content.screencast.com/users/AdnanOrasis/folders/Jing/media/9994446c-6aa7-43cf-8db6-12bdb188bf97/Orasis_Mapping_Studio_Parameterized_Query.swf" allowFullScreen="true" base="http://content.screencast.com/users/AdnanOrasis/folders/Jing/media/9994446c-6aa7-43cf-8db6-12bdb188bf97/" scale="showall"&gt;&lt;/embed&gt; &lt;/object&gt;&lt;/p&gt;

&lt;p&gt;Once the method and assembly are generated we can call them in our application using the following test method and see the results in our application.&lt;/p&gt;

&lt;pre&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; TestParameterizedQueryMethod()
{

	&lt;span style="color: #008000"&gt;//Instantiate the generated DAL Class        &lt;/span&gt;
	SqlServerProject.DataAccess.AdventureDBAccess dataAccess = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SqlServerProject.DataAccess.AdventureDBAccess();
	        
	&lt;span style="color: #008000"&gt;//Execute the method with parameter value 1        &lt;/span&gt;
	IList&amp;lt;Employee&amp;gt; resultsList = dataAccess.EmployeeQueryMapping(1);
	System.Console.WriteLine(&amp;quot;&lt;span style="color: #8b0000"&gt;Results with value {0}: {1}&lt;/span&gt;&amp;quot;,1, resultsList.Count);

	&lt;span style="color: #008000"&gt;//Execute the same method with a null value for the parameter        &lt;/span&gt;
	resultsList = dataAccess.EmployeeQueryMapping(&lt;span style="color: #0000ff"&gt;null&lt;/span&gt;);
	System.Console.WriteLine(&amp;quot;&lt;span style="color: #8b0000"&gt;Results with value {0}: {1}&lt;/span&gt;&amp;quot;,&amp;quot;&lt;span style="color: #8b0000"&gt;null&lt;/span&gt;&amp;quot;, resultsList.Count);

}&lt;/pre&gt;

&lt;pre&gt;&amp;#160;&lt;/pre&gt;

&lt;p&gt;This concludes showing the how easy it is to use Parameterized queries and map them with the Orasis Mapping Studio. The same can be done with different databases by using the correct parameter delimiter.&lt;/p&gt;</description>
      <link>http://feedproxy.google.com/~r/TheOrasisSoftwareBlog/~3/EkPG9KHTn9E/post.aspx</link>
      <author>Adnan</author>
      <comments>http://www.orasissoftware.com/Blog/post/2009/04/04/Develop-your-data-access-layer-using-safe-parameterized-queries.aspx#comment</comments>
      <guid isPermaLink="false">http://www.orasissoftware.com/Blog/post.aspx?id=c52ba0b6-505d-4f94-8015-2af4201c773b</guid>
      <pubDate>Sat, 04 Apr 2009 06:02:07 -1100</pubDate>
      <dc:publisher>Adnan</dc:publisher>
      <pingback:server>http://www.orasissoftware.com/Blog/pingback.axd</pingback:server>
      <pingback:target>http://www.orasissoftware.com/Blog/post.aspx?id=c52ba0b6-505d-4f94-8015-2af4201c773b</pingback:target>
      <slash:comments>253</slash:comments>
      <trackback:ping>http://www.orasissoftware.com/Blog/trackback.axd?id=c52ba0b6-505d-4f94-8015-2af4201c773b</trackback:ping>
      <wfw:comment>http://www.orasissoftware.com/Blog/post/2009/04/04/Develop-your-data-access-layer-using-safe-parameterized-queries.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.orasissoftware.com/Blog/syndication.axd?post=c52ba0b6-505d-4f94-8015-2af4201c773b</wfw:commentRss>
    <feedburner:origLink>http://www.orasissoftware.com/Blog/post.aspx?id=c52ba0b6-505d-4f94-8015-2af4201c773b</feedburner:origLink></item>
    <item>
      <title>How to update a table from an object using the Orasis Mapping Studio</title>
      <description>&lt;p&gt;This video demonstrates how to create a Persist mapping to update a table using the Orasis Mapping Studio’s persist mapping and data access code generation mechanism. &lt;/p&gt; &lt;object id='stU09TREdIR1pXQlReWltfVlVQ' width='425' height='344' type='application/x-shockwave-flash' data='http://www.screentoaster.com/swf/STPlayer.swf'  codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0'&gt;&lt;param name="movie" value="http://www.screentoaster.com/swf/STPlayer.swf" /&gt;&lt;param name="allowFullScreen" value="true" /&gt;&lt;param name="allowScriptAccess" value="always" /&gt;&lt;param name="flashvars" value="video=stU09TREdIR1pXQlReWltfVlVQ" /&gt;&lt;/object&gt;  &lt;div style="width: 425px; text-align: right"&gt;&lt;/div&gt;  &lt;p&gt;Once the code is generated from the Studio and the assembly is successfully built, it can be invoked using the following test method: &lt;/p&gt; &lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;  &lt;pre&gt; 	
&lt;span style="color: #808080"&gt;/// &amp;lt;summary&amp;gt;       &lt;/span&gt;
&lt;span style="color: #808080"&gt;/// Call the Orasis Generated Update Method to Update the Product table        &lt;/span&gt;
&lt;span style="color: #808080"&gt;/// &amp;lt;/summary&amp;gt;        &lt;/span&gt;
&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; UpdateProduct()        
{            
	IList&amp;lt;ProductUpdater&amp;gt; productUpdateList = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;ProductUpdater&amp;gt;();            
	OrasisSoftware.Sample.DataAccess.DataAccessService dal = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; OrasisSoftware.Sample.DataAccess.DataAccessService();            
	ProductUpdater product1 = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ProductUpdater();            
	product1.productid = 1;            
	product1.QuantityPerUnit = &amp;quot;&lt;span style="color: #8b0000"&gt;12 - 14 mg&lt;/span&gt;&amp;quot;;            
	product1.UnitPrice = 20;            
	product1.UnitsInStock = 1;            	
	product1.UnitsOnOrder = 10;            	
	productUpdateList.Add(product1);            

	&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; rowsAffected = dal.UpdateProductById(productUpdateList);        
}&lt;/pre&gt;

&lt;pre class="csharpcode"&gt;&amp;#160;&lt;/pre&gt;

&lt;p&gt;This concludes creating a Persist mapping and generating code to perform an update on a table. The same can be done for Inserting and Deleting by creating a Persist mapping and choosing the right query type. &lt;/p&gt;

&lt;div class="wlWriterEditableSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:0b643796-c01c-417d-9f91-8a89f71a59b3" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/mapping" rel="tag"&gt;mapping&lt;/a&gt;,&lt;a href="http://technorati.com/tags/ado+.net" rel="tag"&gt;ado .net&lt;/a&gt;,&lt;a href="http://technorati.com/tags/sql" rel="tag"&gt;sql&lt;/a&gt;,&lt;a href="http://technorati.com/tags/query" rel="tag"&gt;query&lt;/a&gt;,&lt;a href="http://technorati.com/tags/persist" rel="tag"&gt;persist&lt;/a&gt;,&lt;a href="http://technorati.com/tags/object" rel="tag"&gt;object&lt;/a&gt;,&lt;a href="http://technorati.com/tags/orasis" rel="tag"&gt;orasis&lt;/a&gt;,&lt;a href="http://technorati.com/tags/mapping+studio" rel="tag"&gt;mapping studio&lt;/a&gt;,&lt;a href="http://technorati.com/tags/insert" rel="tag"&gt;insert&lt;/a&gt;,&lt;a href="http://technorati.com/tags/update" rel="tag"&gt;update&lt;/a&gt;,&lt;a href="http://technorati.com/tags/delete" rel="tag"&gt;delete&lt;/a&gt;,&lt;a href="http://technorati.com/tags/c%23" rel="tag"&gt;c#&lt;/a&gt;,&lt;a href="http://technorati.com/tags/.net" rel="tag"&gt;.net&lt;/a&gt;&lt;/div&gt;</description>
      <link>http://feedproxy.google.com/~r/TheOrasisSoftwareBlog/~3/5Ymm0dYedgM/post.aspx</link>
      <author>adnan</author>
      <comments>http://www.orasissoftware.com/Blog/post/2009/03/28/How-to-update-a-table-from-an-object-using-the-Orasis-Mapping-Studio.aspx#comment</comments>
      <guid isPermaLink="false">http://www.orasissoftware.com/Blog/post.aspx?id=a9159fef-c6be-4e43-b322-263c9d83c724</guid>
      <pubDate>Sat, 28 Mar 2009 16:32:00 -1100</pubDate>
      <dc:publisher>adnan</dc:publisher>
      <pingback:server>http://www.orasissoftware.com/Blog/pingback.axd</pingback:server>
      <pingback:target>http://www.orasissoftware.com/Blog/post.aspx?id=a9159fef-c6be-4e43-b322-263c9d83c724</pingback:target>
      <slash:comments>106</slash:comments>
      <trackback:ping>http://www.orasissoftware.com/Blog/trackback.axd?id=a9159fef-c6be-4e43-b322-263c9d83c724</trackback:ping>
      <wfw:comment>http://www.orasissoftware.com/Blog/post/2009/03/28/How-to-update-a-table-from-an-object-using-the-Orasis-Mapping-Studio.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.orasissoftware.com/Blog/syndication.axd?post=a9159fef-c6be-4e43-b322-263c9d83c724</wfw:commentRss>
    <feedburner:origLink>http://www.orasissoftware.com/Blog/post.aspx?id=a9159fef-c6be-4e43-b322-263c9d83c724</feedburner:origLink></item>
    <item>
      <title>Smart Code Generation for Data Access Using Orasis Mapping Studio</title>
      <description>&lt;p&gt;Learn how generate data access code the smart way using mappings and smart code generation. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Download Link: &lt;a href="http://www.orasissoftware.com/download.aspx"&gt;http://www.orasissoftware.com/download.aspx&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Introduction &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Populating objects with data from a database is something almost every application needs to do. Let's say we have a screen in which we want to populate a grid with a given SQL Query using custom object binding of a given object type. What we want to do is to be able to generate a smart Data Access Layer that will do all the work for us and return us the objects populated with data from our query and nothing more. &lt;/p&gt;  &lt;p&gt;To achieve this in a matter of minutes we will use the Orasis Mapping Studio and its Smart Mapping and Code Generation technology. The code that will be generated will only focus on populating the Model objects and returning them in a list, taking in any parameters that are needed. We will show you how the code is generated and then tested and built into an assembly all within the Orasis Mapping Studio that can be simply exported to Microsoft Visual Studio with a click of a button. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Example Scenario: &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Let us take an industry standard query that requires complex joins, sub queries, unions and a few input parameters. This query retrieves a bill of materials for a given product for a given date: &lt;/p&gt; &lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;  &lt;pre&gt;&lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=With&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;With&lt;/a&gt; BOM_cte(ProductAssemblyID, ComponentID, ComponentDesc, PerAssemblyQty,
    StandardCost, ListPrice, BOMLevel, RecursionLevel) &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=As&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;As&lt;/a&gt; (&lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=Select&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;Select&lt;/a&gt;
      b.ProductAssemblyID, b.ComponentID, p.Name, b.PerAssemblyQty,
      p.StandardCost, p.ListPrice, b.BOMLevel, 0
    &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=From&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;From&lt;/a&gt; Production.BillOfMaterials b &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=Inner&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;Inner&lt;/a&gt; &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=Join&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;Join&lt;/a&gt;
      Production.Product p &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=On&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;On&lt;/a&gt; b.ComponentID = p.ProductID
    &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=Where&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;Where&lt;/a&gt; b.ProductAssemblyID = @StartProductID &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=And&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;And&lt;/a&gt; (@CheckDate &amp;gt;= b.StartDate
      &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=And&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;And&lt;/a&gt; @CheckDate &amp;lt;= IsNull(b.EndDate, @CheckDate))
    &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=Union&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;Union&lt;/a&gt; &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=All&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;All&lt;/a&gt;
    &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=Select&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;Select&lt;/a&gt; b.ProductAssemblyID, b.ComponentID, p.Name, b.PerAssemblyQty,
      p.StandardCost, p.ListPrice, b.BOMLevel, RecursionLevel + 1
    &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=From&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;From&lt;/a&gt; BOM_cte cte &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=Inner&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;Inner&lt;/a&gt; &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=Join&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;Join&lt;/a&gt;
      Production.BillOfMaterials b &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=On&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;On&lt;/a&gt; b.ProductAssemblyID = cte.ComponentID
      &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=Inner&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;Inner&lt;/a&gt; &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=Join&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;Join&lt;/a&gt;
      Production.Product p &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=On&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;On&lt;/a&gt; b.ComponentID = p.ProductID
    &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=Where&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;Where&lt;/a&gt; (@CheckDate &amp;gt;= b.StartDate &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=And&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;And&lt;/a&gt; @CheckDate &amp;lt;= IsNull(b.EndDate,
      @CheckDate)))
&lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=Select&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;Select&lt;/a&gt; b.ProductAssemblyID, b.ComponentID, b.ComponentDesc,
  &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=Sum&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;Sum&lt;/a&gt;(b.PerAssemblyQty) &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=As&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;As&lt;/a&gt; TotalQuantity, b.StandardCost, b.ListPrice,
  b.BOMLevel, b.RecursionLevel
&lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=From&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;From&lt;/a&gt; BOM_cte b
&lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=Group&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;Group&lt;/a&gt; &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=By&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;By&lt;/a&gt; b.ProductAssemblyID, b.ComponentID, b.ComponentDesc, b.StandardCost,
  b.ListPrice, b.BOMLevel, b.RecursionLevel
&lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=Order&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;Order&lt;/a&gt; &lt;a style="color: #0000ff" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=By&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99"&gt;By&lt;/a&gt; b.BOMLevel, b.ProductAssemblyID, b.ComponentID&lt;/pre&gt;

&lt;p&gt;The we want to populate the results into a model object called BillOfMaterialModel which has the following properties: &lt;/p&gt;

&lt;p style="text-align: center"&gt;&lt;img height="220" alt="" src="/blog/image.axd?picture=032809_0411_SmartCodeGe1.png" width="333" /&gt; &lt;/p&gt;

&lt;p&gt;The code that needs to get generated to achieve this mapping will perform the work of connecting to the database, executing the query with any of the parameters passed. Then retrieving the results and mapping them into the model object's properties. While doing that it will make sure all the implicit and explicit conversions are done accurately to match the data types. Then it will return the final list of objects in an IList interface. All this will be achieved as a generated partial class with virtual methods that can be overridden with no third party dependencies to any library or any configuration and reflection operations that cost us in performance. &lt;/p&gt;

&lt;p&gt;Let's first look at the end result we want and look at the code that will do the mapping: &lt;/p&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;

&lt;pre&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; AdventureWorks.Objects;
&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System;
&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Collections;
&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Data;
&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Data.SqlClient;

&lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; AdventureWorks.DataAccess
{
    
    
    &lt;span style="color: #808080"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #808080"&gt;/// &lt;/span&gt;
    &lt;span style="color: #808080"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; partial &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; ProductsDALClass
    {
        
        &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; String _connectionString = &amp;quot;&lt;span style="color: #8b0000"&gt;Data Source=localhost;Initial Catalog=AdventureWorks;Integrated Security&lt;/span&gt;&amp;quot; +
            &amp;quot;&lt;span style="color: #8b0000"&gt;=True&lt;/span&gt;&amp;quot;;
        
        &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;virtual&lt;/span&gt; String ConnectionString
        {
            &lt;span style="color: #0000ff"&gt;get&lt;/span&gt;
            {
                &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;._connectionString;
            }
            &lt;span style="color: #0000ff"&gt;set&lt;/span&gt;
            {
                &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;._connectionString = &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;;
            }
        }
        
        &lt;span style="color: #808080"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span style="color: #808080"&gt;/// This method returns the Bill Of Materials for a given ProductId and a check date.&lt;/span&gt;
        &lt;span style="color: #808080"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; IList&amp;lt;BillOfMaterialsModel&amp;gt; GetBillOfMaterials(System.Nullable&amp;lt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&amp;gt; StartProductID, System.Nullable&amp;lt;System.DateTime&amp;gt; CheckDate)
        {
            System.Data.IDbCommand command;
            IDataReader dataReader = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;
            List&amp;lt;BillOfMaterialsModel&amp;gt; returnList = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;BillOfMaterialsModel&amp;gt;();
            IDbConnection connection = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; System.Data.SqlClient.SqlConnection(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.ConnectionString);
            &lt;span style="color: #0000ff"&gt;try&lt;/span&gt;
            {
                connection.Open();
                command = connection.CreateCommand();
		command.CommandText = @&amp;quot;&lt;span style="color: #8b0000"&gt;With BOM_cte(ProductAssemblyID, ComponentID, ComponentDesc, PerAssemblyQty,
		    StandardCost, ListPrice, BOMLevel, RecursionLevel) As (Select
		      b.ProductAssemblyID, b.ComponentID, p.Name, b.PerAssemblyQty,
		      p.StandardCost, p.ListPrice, b.BOMLevel, 0
		    From Production.BillOfMaterials b Inner Join
		      Production.Product p On b.ComponentID = p.ProductID
		    Where b.ProductAssemblyID = @StartProductID And @CheckDate &amp;gt;= b.StartDate
		      And @CheckDate &amp;lt;= ISNULL(b.EndDate, @CheckDate)
		    Union All
		    Select b.ProductAssemblyID, b.ComponentID, p.Name, b.PerAssemblyQty,
		      p.StandardCost, p.ListPrice, b.BOMLevel, RecursionLevel + 1
		    From BOM_cte cte Inner Join
		      Production.BillOfMaterials b On b.ProductAssemblyID = cte.ComponentID
	            Inner Join
		      Production.Product p On b.ComponentID = p.ProductID
		    Where @CheckDate &amp;gt;= b.StartDate And @CheckDate &amp;lt;= ISNULL(b.EndDate,
		      @CheckDate))
	            Select b.ProductAssemblyID, b.ComponentID, b.ComponentDesc,
			  Sum(b.PerAssemblyQty) As TotalQuantity, b.StandardCost, b.ListPrice,
			  b.BOMLevel, b.RecursionLevel
		    From BOM_cte b
		    Group By b.ProductAssemblyID, b.ComponentID, b.ComponentDesc, b.StandardCost,
			  b.ListPrice, b.BOMLevel, b.RecursionLevel
		    Order By b.BOMLevel, b.ProductAssemblyID, b.ComponentID&lt;/span&gt;&amp;quot;;

                System.Console.WriteLine(&amp;quot;&lt;span style="color: #8b0000"&gt;Executing Query: {0}&lt;/span&gt;&amp;quot;, command.CommandText);
                IDbDataParameter param_StartProductID = command.CreateParameter();
                param_StartProductID.ParameterName = &amp;quot;&lt;span style="color: #8b0000"&gt;StartProductID&lt;/span&gt;&amp;quot;;
                &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; ((StartProductID == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;))
                {
                    param_StartProductID.Value = DBNull.Value;
                }
                &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;
                {
                    param_StartProductID.Value = StartProductID;
                }
                command.Parameters.Add(param_StartProductID);
                IDbDataParameter param_CheckDate = command.CreateParameter();
                param_CheckDate.ParameterName = &amp;quot;&lt;span style="color: #8b0000"&gt;CheckDate&lt;/span&gt;&amp;quot;;
                &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; ((CheckDate == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;))
                {
                    param_CheckDate.Value = DBNull.Value;
                }
                &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;
                {
                    param_CheckDate.Value = CheckDate;
                }
                command.Parameters.Add(param_CheckDate);
                dataReader = command.ExecuteReader();
                &lt;span style="color: #0000ff"&gt;for&lt;/span&gt; (
                ; dataReader.Read(); 
                )
                {

                    BillOfMaterialsModel modelObj = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; BillOfMaterialsModel();
                    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; ((dataReader[&amp;quot;&lt;span style="color: #8b0000"&gt;ProductAssemblyID&lt;/span&gt;&amp;quot;].Equals(DBNull.Value) == &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;))
                    {
                        modelObj.ProductAssemblyID = ((&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)(dataReader[&amp;quot;&lt;span style="color: #8b0000"&gt;ProductAssemblyID&lt;/span&gt;&amp;quot;]));
                    }
                    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; ((dataReader[&amp;quot;&lt;span style="color: #8b0000"&gt;ComponentID&lt;/span&gt;&amp;quot;].Equals(DBNull.Value) == &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;))
                    {
                        modelObj.ComponentID = ((&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)(dataReader[&amp;quot;&lt;span style="color: #8b0000"&gt;ComponentID&lt;/span&gt;&amp;quot;]));
                    }
                    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; ((dataReader[&amp;quot;&lt;span style="color: #8b0000"&gt;ComponentDesc&lt;/span&gt;&amp;quot;].Equals(DBNull.Value) == &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;))
                    {
                        modelObj.ComponentDesc = ((&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;)(dataReader[&amp;quot;&lt;span style="color: #8b0000"&gt;ComponentDesc&lt;/span&gt;&amp;quot;]));
                    }
                    &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;
                    {
                        modelObj.ComponentDesc = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;
                    }
                    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; ((dataReader[&amp;quot;&lt;span style="color: #8b0000"&gt;TotalQuantity&lt;/span&gt;&amp;quot;].Equals(DBNull.Value) == &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;))
                    {
                        modelObj.TotalQuantity = ((&lt;span style="color: #0000ff"&gt;decimal&lt;/span&gt;)(dataReader[&amp;quot;&lt;span style="color: #8b0000"&gt;TotalQuantity&lt;/span&gt;&amp;quot;]));
                    }
                    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; ((dataReader[&amp;quot;&lt;span style="color: #8b0000"&gt;StandardCost&lt;/span&gt;&amp;quot;].Equals(DBNull.Value) == &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;))
                    {
                        modelObj.StandardCost = ((&lt;span style="color: #0000ff"&gt;decimal&lt;/span&gt;)(dataReader[&amp;quot;&lt;span style="color: #8b0000"&gt;StandardCost&lt;/span&gt;&amp;quot;]));
                    }
                    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; ((dataReader[&amp;quot;&lt;span style="color: #8b0000"&gt;ListPrice&lt;/span&gt;&amp;quot;].Equals(DBNull.Value) == &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;))
                    {
                        modelObj.ListPrice = ((&lt;span style="color: #0000ff"&gt;decimal&lt;/span&gt;)(dataReader[&amp;quot;&lt;span style="color: #8b0000"&gt;ListPrice&lt;/span&gt;&amp;quot;]));
                    }
                    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; ((dataReader[&amp;quot;&lt;span style="color: #8b0000"&gt;BOMLevel&lt;/span&gt;&amp;quot;].Equals(DBNull.Value) == &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;))
                    {
                        modelObj.BOMLevel = ((&lt;span style="color: #0000ff"&gt;short&lt;/span&gt;)(dataReader[&amp;quot;&lt;span style="color: #8b0000"&gt;BOMLevel&lt;/span&gt;&amp;quot;]));
                    }
                    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; ((dataReader[&amp;quot;&lt;span style="color: #8b0000"&gt;RecursionLevel&lt;/span&gt;&amp;quot;].Equals(DBNull.Value) == &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;))
                    {
                        modelObj.RecursionLevel = ((&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)(dataReader[&amp;quot;&lt;span style="color: #8b0000"&gt;RecursionLevel&lt;/span&gt;&amp;quot;]));
                    }
                    returnList.Add(modelObj);
                }
            }
            &lt;span style="color: #0000ff"&gt;finally&lt;/span&gt;
            {
                connection.Close();
                ((System.IDisposable)(connection)).Dispose();
            }
            &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; returnList;
        }
    }
}&lt;/pre&gt;

&lt;p&gt;After this code is generated we will be able to simply call the method in our generated DAL library to get us the results in an object and show them in our grid.&lt;span style="font-size: 10pt; font-family: courier new"&gt; &lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step by Step Walkthrough &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We will begin by launching the Orasis Mapping Studio and connecting to our database. &lt;/p&gt;

&lt;p&gt;&lt;img height="439" alt="" src="/blog/image.axd?picture=032809_0411_SmartCodeGe2.png" width="628" /&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Start a Mapping &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Then we will begin creating a mapping through the &amp;quot;Add Mapping&amp;quot; wizard. The first step is providing a name to identify our mapping and what type of mapping it is: &lt;/p&gt;

&lt;p&gt;&lt;img height="481" alt="" src="/blog/image.axd?picture=032809_0411_SmartCodeGe3.png" width="628" /&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Enter your SQL Query &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Then we will enter our query or build it in the query designer, whichever suits the developer. &lt;/p&gt;

&lt;p&gt;&lt;img height="481" alt="" src="/blog/image.axd?picture=032809_0411_SmartCodeGe4.png" width="628" /&gt; &lt;/p&gt;

&lt;p&gt;The query will be taken in and checked for any errors. Then we can also see the query in design mode to get an idea of the tables and relationships being used in the query: &lt;/p&gt;

&lt;p&gt;&lt;img height="481" alt="" src="/blog/image.axd?picture=032809_0411_SmartCodeGe5.png" width="628" /&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Select your Object &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Then we will move to the next step in our mapping wizard where we select the object that needs to get populated from our object's Assembly. &lt;/p&gt;

&lt;p&gt;&lt;img height="481" alt="" src="/blog/image.axd?picture=032809_0411_SmartCodeGe6.png" width="628" /&gt; &lt;/p&gt;

&lt;p style="text-align: center"&gt;Figure 8. Mapping Step 3: Selecting the Class to map the query result &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Map the Fields &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Next we will go to the mapping screen which allows us to map the query's return columns into the Object's properties field by field. &lt;/p&gt;

&lt;p&gt;&lt;img height="481" alt="" src="/blog/image.axd?picture=032809_0411_SmartCodeGe7.png" width="628" /&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Set Code Options &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the final step we will specify the name of the method and the class that the code for this mapping will get generated into. &lt;/p&gt;

&lt;p&gt;&lt;img height="481" alt="" src="/blog/image.axd?picture=032809_0411_SmartCodeGe8.png" width="628" /&gt; &lt;/p&gt;

&lt;p&gt;Once we are finished creating the mapping we can see the mapping get added to our project and we can see the generated code and classes all in the project explorer: &lt;/p&gt;

&lt;p&gt;&lt;img height="305" alt="" src="/blog/image.axd?picture=032809_0411_SmartCodeGe9.png" width="245" /&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6: Build your Output &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;img height="96" alt="" src="/blog/image.axd?picture=032809_0411_SmartCodeGe10.png" width="290" /&gt; &lt;/p&gt;

&lt;p&gt;That's it. We are done with mapping our query to our object. Now all we need to do is hit the Build button and the Orasis Mapping Studio takes all the mapping information and generates all the class files and code to get the data we need in the object specified. It also compiles the code into a .NET assembly that we can use in our UI project directly and call the methods. The output folder for the generated code looks like the following. It gets created next to the location of the project file for the Orasis Mapping Studio. 
  &lt;br /&gt;

  &lt;br /&gt;/Output/ProductDALClass.cs 

  &lt;br /&gt;/Bin/MySmartDal.dll &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Unit Test &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before we actually call the method in our Application or UI, we want to make sure the code we generated executes correctly, bringing us the results we expect in the timing we need. To achieve that we can launch the Tester and execute the method we want to test. It will prompt us for the necessary parameters and show us the results with row counts and timings as following: &lt;/p&gt;

&lt;p&gt;&lt;img height="254" alt="" src="/blog/image.axd?picture=032809_0411_SmartCodeGe11.png" width="628" /&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using the Data Access Library in your Project&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Now, we can simply open our Application project and call the generated MySmartDal.dll in our code and get the results shown in a grid with the following code behind a windows form: &lt;/p&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;

&lt;pre&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System;
&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Windows.Forms;
&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; MySmartDAL.BillOfMaterials;

&lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; ProductViewerSample
{
    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; partial &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Form1 : Form
    {
        &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; Form1()
        {
            InitializeComponent();
        }
        &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; btnGetBillOfMaterials_Click(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; sender, EventArgs e)
        {
            ProductsDALClass dalClass = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ProductsDALClass();
            &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; productId = &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;.Parse(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.textBox1.Text);

	    &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.dataGridViewBOM.DataSource = dalClass.GetBillOfMaterials(productId, &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.dateTimePicker1.Value);
        }
    }
}&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Running your application &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Running the application code and the data access generated code brings us the following result screen: &lt;/p&gt;

&lt;p&gt;&lt;img height="428" alt="" src="/blog/image.axd?picture=032809_0411_SmartCodeGe12.png" width="628" /&gt; &lt;/p&gt;

&lt;p style="text-align: center"&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exporting to Visual Studio &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We can also export all the output code to a Visual Studio Project file and launch it in Visual Studio 2005 or 2008. &lt;/p&gt;

&lt;p&gt;&lt;img height="98" alt="" src="/blog/image.axd?picture=032809_0411_SmartCodeGe13.png" width="324" /&gt; &lt;/p&gt;

&lt;p&gt;Clicking on the Launch Project in Visual Studio will open our sample project in Visual Studio with all the generated code files, projects and project references set up for you. &lt;/p&gt;

&lt;p&gt;&lt;img height="174" alt="" src="/blog/image.axd?picture=032809_0411_SmartCodeGe14.png" width="628" /&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This concludes building a quick, efficient, object oriented, well abstracted data access layer that satisfies our business requirements in an automated, managed, and testable way in only a few minutes. The Mapping project can then be expanded to create mappings for different business requirements the application may have, each using a query, object and field mappings. All managed in one data access management and code generation studio. &lt;/p&gt;

&lt;p&gt;You can download the Orasis Mapping Studio from &lt;a href="http://www.orasissoftware.com"&gt;http://www.orasissoftware.com&lt;/a&gt;. It has a full feature 30 day trial version with full support to get you started. Start building data access&lt;span style="color: red"&gt; &lt;/span&gt;code the smart way! &lt;/p&gt;

&lt;div class="wlWriterEditableSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:3482e976-0b10-4f7b-bd26-a10b9fbe7d58" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/orasis" rel="tag"&gt;orasis&lt;/a&gt;,&lt;a href="http://technorati.com/tags/.net+mapping" rel="tag"&gt;.net mapping&lt;/a&gt;,&lt;a href="http://technorati.com/tags/code+generation" rel="tag"&gt;code generation&lt;/a&gt;,&lt;a href="http://technorati.com/tags/sql" rel="tag"&gt;sql&lt;/a&gt;,&lt;a href="http://technorati.com/tags/data+access" rel="tag"&gt;data access&lt;/a&gt;,&lt;a href="http://technorati.com/tags/dal" rel="tag"&gt;dal&lt;/a&gt;,&lt;a href="http://technorati.com/tags/object" rel="tag"&gt;object&lt;/a&gt;,&lt;a href="http://technorati.com/tags/mapping+studio" rel="tag"&gt;mapping studio&lt;/a&gt;,&lt;a href="http://technorati.com/tags/mapping" rel="tag"&gt;mapping&lt;/a&gt;&lt;/div&gt;</description>
      <link>http://feedproxy.google.com/~r/TheOrasisSoftwareBlog/~3/w1r9mHjIlaY/post.aspx</link>
      <author>Adnan</author>
      <comments>http://www.orasissoftware.com/Blog/post/2009/03/28/Smart-Code-Generation-for-Data-Access-Using-Orasis-Mapping-Studio.aspx#comment</comments>
      <guid isPermaLink="false">http://www.orasissoftware.com/Blog/post.aspx?id=673f0b30-4f19-4e7c-943b-2668d6947c4f</guid>
      <pubDate>Sat, 28 Mar 2009 03:53:00 -1100</pubDate>
      <dc:publisher>Adnan</dc:publisher>
      <pingback:server>http://www.orasissoftware.com/Blog/pingback.axd</pingback:server>
      <pingback:target>http://www.orasissoftware.com/Blog/post.aspx?id=673f0b30-4f19-4e7c-943b-2668d6947c4f</pingback:target>
      <slash:comments>343</slash:comments>
      <trackback:ping>http://www.orasissoftware.com/Blog/trackback.axd?id=673f0b30-4f19-4e7c-943b-2668d6947c4f</trackback:ping>
      <wfw:comment>http://www.orasissoftware.com/Blog/post/2009/03/28/Smart-Code-Generation-for-Data-Access-Using-Orasis-Mapping-Studio.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.orasissoftware.com/Blog/syndication.axd?post=673f0b30-4f19-4e7c-943b-2668d6947c4f</wfw:commentRss>
    <feedburner:origLink>http://www.orasissoftware.com/Blog/post.aspx?id=673f0b30-4f19-4e7c-943b-2668d6947c4f</feedburner:origLink></item>
  </channel>
</rss>

