Welcome to weblogs.com.pk Sign in | Join | Help

DNN4 :: Enterprise Library

Last month; when my team started working on a very exciting new project; we all decided that we will use .NET v2 for all aspects of the project. We still are trying to make SQL 2005 available for this project; its new features like Service Broker will definitely help us.

Anyways; last week I disconnect myself from that project to complete couple of things that some of the developers on the team were previously working. While fixing couple of issues I found an opportunity to separate out one of the module and develop it from scratch using ASP.NET v2. Fortunately all the foundation was in place; so doing it was pretty straight forward; thanks to SqlDataSource.

Yesterday I got another free day; so I invested that time in learning DotNetNuke 4 (DNN); one thing is pretty noticeable; DNN4 is much more cleaner than DNN 3.x; thanks to Visual Studio Templates; you can create DNN4 site and its new module very easily. Another good aspect is; as ASP.NET v2 now supports dynamic compilation; you can configure different compilers for different folders in a single web site. Using this; even though DNN is Visual Basic based; you can create modules in the same project with other languages like C# or J#. Thumbs up for the ASP.NET team to exploit features of Common Language Runtime. Summing things up; working with DNN4 was pretty straight forward; and I was able to port my ASCX and their “code besides” into DNN4 and my that little component now has pretty nice user interface; and thanks to DNN4 I got lot of other features for free <smile />

Today while reading other’s weblogs I came to know that Microsoft.NET Enterprise Library for .NET v2 is out; so I decided to give it a try on the same project. Here are little notes of mine on using its Data block.

  • After installing and building the library; simply copy Microsoft.Practices.EnterpriseLibrary.Common.dll, Microsoft.Practices.EnterpriseLibrary.Data.dll and Microsoft.Practices.ObjectBuilder.dll (you should copy their respective XML files as well for IntelliSence) to your lib folder and add their references
  • In your config (web.config) file; add the following in <configSections />

<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data" />

  • In the config, create a section, dataConfiguration and set its defaultDatabase property to the connection string name; defined in <connectionStrings> section. For complete config; see the library’s quick start project config file

Here is a sample code to get the dataset using the library

using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;

public static DataSet GetIssuedItemsDetail(string loggedInUserID)
{
 Database db = DatabaseFactory.CreateDatabase();
 string sql = "GetIssuedItems";
 DbCommand cmd = db.GetStoredProcCommand(sql);
 db.AddInParameter(cmd, "@LoggedInUserID", DbType.String, loggedInUserID);
 return db.ExecuteDataSet(cmd);
}

Using enterprise library I have developed a small class library with couple of static methods across few public classes. Now I have replaced SqlDataSource with ObjectDataSource and I am feeling more satisfied that the SQL queries and stored-proc names are not written in user interface. If I find some time next week for this project; I will try to incorporate provider model. With that my user interface layer will get completely disconnected and flexibile enough to work with any of its providers. I will post the notes on implementing .NET provider model when it will be done…

And finally...have a great weekend!

Published Saturday, January 21, 2006 4:50 PM by khurram
Filed under: , ,

Comments

# re: DNN4 :: Enterprise Library

Saturday, January 21, 2006 6:35 PM by khurram
BTW; the easiest method to get your config files updated is to use "EntLibConfig.exe" from Enterprise library's bin folder. Its a GUI based app configuration manager and you can get your app's config file updated with just couple of mouse clicks.
New Comments to this post are disabled