<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://v900u039rux.maximumasp.com/Web/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Manjula&amp;#39;s Blog : ASP.Net, C#</title><link>http://v900u039rux.maximumasp.com/Web/blogs/mperera/archive/tags/ASP.Net/C_2300_/default.aspx</link><description>Tags: ASP.Net, C#</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP2 (Build: 20611.960)</generator><item><title>SubSonic - Part 1 - An Introduction</title><link>http://v900u039rux.maximumasp.com/Web/blogs/mperera/archive/2008/01/03/subsonic-part-1-an-introduction.aspx</link><pubDate>Thu, 03 Jan 2008 06:27:00 GMT</pubDate><guid isPermaLink="false">3790bee0-d05b-4b84-a272-3ed522a0473a:131</guid><dc:creator>Manjula Perera</dc:creator><slash:comments>8</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://v900u039rux.maximumasp.com/Web/blogs/mperera/rsscomments.aspx?PostID=131</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://v900u039rux.maximumasp.com/Web/blogs/mperera/commentapi.aspx?PostID=131</wfw:comment><comments>http://v900u039rux.maximumasp.com/Web/blogs/mperera/archive/2008/01/03/subsonic-part-1-an-introduction.aspx#comments</comments><description>&lt;p&gt;&lt;strong&gt;&lt;img title="SubSonic logo" style="WIDTH:320px;HEIGHT:60px;" height="60" alt="SubSonic logo" src="http://dnfug.com/Web/blogs/mperera/subsonic_logo.png" width="320" /&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Overview&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This is another interesting article about the new trends of the software industry. I would like to share the information I gathered while researching on this new toolset with the user group members and the readers of this blog.&amp;nbsp;I thought of writing about &lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;SubSonic&lt;/font&gt; because it&amp;#39;s another way of accessing/ Querying the database (Actually, &lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;SubSonic&lt;/font&gt; is a third party&amp;nbsp;toolset to auto generate the Data Access Layer (DAL) of our application and maintain it when the database changes). This is just another handy tool for us as LINQ.&amp;nbsp;Therefore I&amp;#39;ll write about &lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;SubSonic&lt;/font&gt; in parallel to the LINQ articles. We can compare LINQ and &lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;SubSonic&lt;/font&gt; later on. Since this is the first article about &lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;SubSonic&lt;/font&gt; in this forum I&amp;#39;ll start with an introduction.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What is &lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;SubSonic&lt;/font&gt;?&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;SubSonic&lt;/font&gt;, initially named as ActionPack is developed as an open source project by &lt;font color="#cc9900"&gt;&lt;a class="" title="@ Microsoft" href="http://blog.wekeroad.com/" target="_blank"&gt;Rob Conery&lt;/a&gt;&lt;/font&gt; before he joined Microsoft, but who is&amp;nbsp;currently&amp;nbsp;working for Microsoft in the ASP.Net team under &lt;a class="" title="@ Microsoft" href="http://weblogs.asp.net/scottgu/" target="_blank"&gt;Scott Guthrie&lt;/a&gt;. The other team members of this project are &lt;a class="" title="His Blog" href="http://monk.thelonio.us/" target="_blank"&gt;Eric Kemp&lt;/a&gt;, Scott Watermasysk, &lt;a class="" href="http://weblogs.asp.net/jgalloway/default.aspx" target="_blank"&gt;Jon Galloway&lt;/a&gt;, &lt;a class="" title="@ Microsoft" href="http://www.haacked.com/" target="_blank"&gt;Phil Haack&lt;/a&gt;, and &lt;a class="" title="His Blog" href="http://weblogs.asp.net/gavinjoyce/default.aspx" target="_blank"&gt;Gavin Joyce&lt;/a&gt;. This project has got attention from Microsoft&amp;nbsp;even though it is still an open source project.&amp;nbsp;&lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;SubSonic&lt;/font&gt; will be developed on top of ASP.Net and the new MVC framework that Microsoft has given more attention of. (This information is true at the time of writing this article and as per the &lt;a class="" href="http://subsonicproject.com/" target="_blank"&gt;&lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;SubSonic&lt;/font&gt; Project&lt;/a&gt;&amp;nbsp;&amp;amp; &lt;a class="" href="http://blog.wekeroad.com/2007/10/26/microsoft-subsonic-and-me/" target="_blank"&gt;Rob Conery&amp;#39;s comments&lt;/a&gt;)&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;We can download the latest&amp;nbsp;source code &lt;a class="" title="SubSonic Source Code" href="http://subsonicproject.com/" target="_blank"&gt;here&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;SubSonic&lt;/font&gt; is a toolset that helps a website build itself. It brings some of the fun and elegance of Ruby on Rails to ASP.NET&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;This implements &lt;a class="" href="http://en.wikipedia.org/wiki/Active_record_pattern" target="_blank"&gt;Active Record&lt;/a&gt; design pattern.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Helps us quickly build data driven websites without writing data manipulation code&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Has a DAL generator that enables us to rapidly create strongly typed collections and CRUD (Create, Read, Update and Delete) enabled objects, which represent the selected database tables&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Has an&amp;nbsp;&lt;a class="" href="http://en.wikipedia.org/wiki/Object-relational_mapping" target="_blank"&gt;object relational (OR)&amp;nbsp;mapper&lt;/a&gt; which extends to stored procedures and views&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Could also automatically generate the UI for the data manipulation tasks&amp;nbsp;(scaffolding support). This is very handy when creating the admin panel of a data driven web applications. We don&amp;#39;t need to worry about creating it from scratch&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Has a dynamic query tool that let us use SQL Server, MySQL and Enterprise Library (Application Blocks) without having to know the underlying SQL syntax (Lets go into technical details in the next articles to follow)&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;We&amp;nbsp;just need to give the reference to the &lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;SubSonic&lt;/font&gt; DLL and set &lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;SubSonic&lt;/font&gt; settings in the Web.config file to make use of the power of &lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;SubSonic&lt;/font&gt; (Lets go into technical details in the next articles to follow)&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Saves lot of development time and that is the main objective of creating &lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;SubSonic&lt;/font&gt;. Will our bosses give more work for the time we save using SubSonic? &lt;img src="http://dnfug.com/Web/emoticons/emotion-15.gif" alt="Geeked" /&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Summery&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;SubSonic&lt;/font&gt;&amp;nbsp;is an open source tool set to auto generate data manipulation code and interfaces. This works on top of ASP.Net and the MVC framework. This gives an extension and a cool new addition to the strength of .Net compliance languages and most importantly this SAVES lot of development time.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Rule Of Thumb&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m pretty sure&amp;nbsp;&lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;SubSonic&lt;/font&gt; will not replace classic SQL, T/SQL or PL/SQL but it will extend the&amp;nbsp;data manipulation&amp;nbsp;capability of the programmer. IT saves lot of time.&amp;nbsp;It&amp;#39;s a pretty cool tool to be in our tool box.&amp;nbsp;We as the programmers must decide when to use it and when not to.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;References&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="http://subsonicproject.com/" target="_blank"&gt;&lt;font style="BACKGROUND-COLOR:#ffff00;"&gt;SubSonic&lt;/font&gt; Project&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class="" title="Previous project site" href="http://dnfug.com/Web/blogs/mperera/subsonic_logo.png" target="_blank"&gt;SubSonic at CodePlex&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="http://blog.wekeroad.com/" target="_blank"&gt;Reb Conery&amp;#39;s weblog&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="http://scribesonic.com/Blog/Category/SubSonic.aspx" target="_blank"&gt;ScribeSonic&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="http://johnnycoder.com/blog/2006/11/05/subsonic-another-look-at-code-generation/" target="_blank"&gt;Jonny Coder&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://v900u039rux.maximumasp.com/Web/aggbug.aspx?PostID=131" width="1" height="1"&gt;</description><category domain="http://v900u039rux.maximumasp.com/Web/blogs/mperera/archive/tags/ASP.Net+2.0/default.aspx">ASP.Net 2.0</category><category domain="http://v900u039rux.maximumasp.com/Web/blogs/mperera/archive/tags/ASP.Net+3.5/default.aspx">ASP.Net 3.5</category><category domain="http://v900u039rux.maximumasp.com/Web/blogs/mperera/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://v900u039rux.maximumasp.com/Web/blogs/mperera/archive/tags/ASP.Net/default.aspx">ASP.Net</category><category domain="http://v900u039rux.maximumasp.com/Web/blogs/mperera/archive/tags/SubSonic/default.aspx">SubSonic</category></item><item><title>Beware with Math.Round() in C#</title><link>http://v900u039rux.maximumasp.com/Web/blogs/mperera/archive/2007/12/26/issue-with-math-round-in-c.aspx</link><pubDate>Wed, 26 Dec 2007 07:44:00 GMT</pubDate><guid isPermaLink="false">3790bee0-d05b-4b84-a272-3ed522a0473a:123</guid><dc:creator>Manjula Perera</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://v900u039rux.maximumasp.com/Web/blogs/mperera/rsscomments.aspx?PostID=123</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://v900u039rux.maximumasp.com/Web/blogs/mperera/commentapi.aspx?PostID=123</wfw:comment><comments>http://v900u039rux.maximumasp.com/Web/blogs/mperera/archive/2007/12/26/issue-with-math-round-in-c.aspx#comments</comments><description>&lt;p&gt;&lt;strong&gt;Problem&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Recently I found an issue with the Math.Round() function in C# while working on an enhancement project written in Visual Studio 2003.&amp;nbsp;I.e. this function is using the Banker&amp;#39;s method.&amp;nbsp;The users of this system didn&amp;#39;t like the way figures are getting rounded&amp;nbsp;and they wanted the method used in Excel (Because they are used to Excel &lt;img src="http://dnfug.com/Web/emoticons/emotion-18.gif" alt="Huh?" /&gt;). I.e. Symmetric Arithmetic Rounding method. E.g&lt;/p&gt;
&lt;p&gt;Say we want to round 1234.50000 into the nearest integer value. Then Math.Round() returns 1234 whereas MS Excel gives 1235.&lt;/p&gt;
&lt;p&gt;I also found&amp;nbsp;a similar&amp;nbsp;issue in SQL Server 2000&amp;nbsp;some time back. It seems that Microsoft&amp;nbsp;uses contradictory methods of rounding in their products (Visual Studio, SQL Server, Visual Basic, Excel etc.)&amp;nbsp;&lt;img src="http://dnfug.com/Web/emoticons/emotion-7.gif" alt="Tongue Tied" /&gt;&lt;/p&gt;
&lt;p&gt;Most of us learnt this banker&amp;#39;s&amp;nbsp;method while schooling. But it seems that there are many other ways of rounding. Click &lt;a class="" title="Rounding methods used in Microsoft products" href="http://support.microsoft.com/kb/196652" target="_blank"&gt;here&lt;/a&gt; to view all methods of rounding and how you can implement custom rounding procedures.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;font color="#0099cc"&gt;Visual Studio 2003&lt;/font&gt;&lt;/em&gt; - If we want to use Symmetric Arithmetic Rounding method we have to write our own function instead of using Math.Round(). See below for a working function found in &lt;a class="" title="Custom rounding algorithm" href="http://www.codersource.net/csharp_math_round.aspx" target="_blank"&gt;CoderSource.Net&lt;/a&gt;.&lt;/p&gt;&lt;font color="#0000ff" size="2"&gt;
&lt;blockquote&gt;
&lt;p&gt;public&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;static&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;double&lt;/font&gt;&lt;font size="2"&gt; roundNum(&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;double&lt;/font&gt;&lt;font size="2"&gt; num, &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;int&lt;/font&gt;&lt;font size="2"&gt; place)&lt;br /&gt;{ &lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;
&lt;blockquote&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;double&lt;/font&gt;&lt;font size="2"&gt; n; &lt;br /&gt;n = num * Math.Pow(10, place); &lt;br /&gt;n = Math.Sign(n) * Math.Abs(Math.Floor(n + .5)); &lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;return&lt;/font&gt;&lt;font size="2"&gt; n / Math.Pow(10, place); &lt;/font&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;font size="2"&gt;} &lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;em&gt;&lt;font color="#0099cc"&gt;Visual Studio 2005&lt;/font&gt;&lt;/em&gt; - This problem is sorted in this version of Visual Studio.&amp;nbsp;We can now select the rounding method in;&lt;/font&gt;&lt;/p&gt;
&lt;blockquote&gt;&lt;font size="2"&gt;&lt;font size="2"&gt;
&lt;p&gt;System.&lt;/font&gt;&lt;font color="#008080" size="2"&gt;Math&lt;/font&gt;&lt;font size="2"&gt;.Round&lt;/p&gt;&lt;/font&gt;&lt;/blockquote&gt;&lt;/font&gt;
&lt;p&gt;&lt;strong&gt;Rule Of Thumb&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;u&gt;Always&lt;/u&gt; ask from the users which method of rounding they want during the system requirements gathering stage. This will avoid&amp;nbsp;us being using the default method of rounding in our chosen development language. In this case C#.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;References&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class="" title="Methods of Rounding" href="http://en.wikipedia.org/wiki/Rounding" target="_blank"&gt;Wikipedia&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class="" title="How To Implement Custom Rounding Procedures" href="http://support.microsoft.com/kb/196652" target="_blank"&gt;Microsoft Help and Support&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class="" title="Custom rounding algorithm" href="http://www.codersource.net/csharp_math_round.aspx" target="_blank"&gt;CoderSource.Net&lt;/a&gt;&lt;/p&gt;&lt;img src="http://v900u039rux.maximumasp.com/Web/aggbug.aspx?PostID=123" width="1" height="1"&gt;</description><category domain="http://v900u039rux.maximumasp.com/Web/blogs/mperera/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://v900u039rux.maximumasp.com/Web/blogs/mperera/archive/tags/ASP.Net/default.aspx">ASP.Net</category><category domain="http://v900u039rux.maximumasp.com/Web/blogs/mperera/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item></channel></rss>