Friday, March 7, 2008

Examples using Enterprise Library Data Access Application Block

These are examples of using the Enterprise Library Data Access Application block.


using Microsoft.Practices.EnterpriseLibrary.Data.Sql;

public MyDataset.MyEntityDataTable GetAllEntities()
{
SqlDatabase db = new SqlDatabase(this.ConnectionString);
StringBuilder sql = new StringBuilder();
sql.Append("dbo.my_entity_select_all");

using (DbCommand command = db.GetStoredProcCommand(sql.ToString()))
{

using (MyDataset.MyEntityDataTable dt = new MyDataset.MyEntityDataTable())
{
using (IDataReader reader = db.ExecuteReader(command))
{
while (reader.Read())
{
AddMyEntityRow(dt, reader);
}
return dt;
}
}
}
}



public MyDataset.MyEntityDataTable GetMyEntity(string MyEntityId)
{

SqlDatabase db = new SqlDatabase(this.ConnectionString);
StringBuilder sql = new StringBuilder();

sql.Append("dbo.My_Entity_Select_By_My_Entity_ID);

using (DbCommand command = db.GetStoredProcCommand(sql.ToString()))
{
db.AddInParameter(command, "
@EntityId", DbType.String, Entity_Alias);
using (MyDataset.MyEntityDataTable dt = new MyDataset.MyEntityDataTable())
{
using (IDataReader reader = db.ExecuteReader(command))
{
while(reader.Read())
{
AddMyEntityRow(dt, reader);
}
return dt;
}
}
}
}

Thursday, February 21, 2008

Custom Configuration Sections

Here are a couple of good links related to creating CustomConfigurations in .NET applications.  This link from dotnetslackers.com gives the simplest explanation I've found so far.
 
This example explains using Collections in your custom config.  Really cool!!!  If you want the basics, check out this article on MSDN.

Monday, January 28, 2008

New C# Features

There is an interesting article on DevX.com about new C# features written by Wei-Meng Lee.  It is the first in a series of other articles to come.  This article covers Implicit typing, automatic properties, collection initializers, and labmda expressions.  Check it out!

Thursday, January 24, 2008

Cool C# and VB Language Comparison

I found a cool comparison chart on C# and VB.Net provided by Frank McCown.  It is really helpful if you find yourself going back and forth between C# and VB.Net.  Check it out!

Wednesday, January 23, 2008

First Post

Announcing the blog on Bob's Training Shack. No, my name is not Bob. Bob is just a plain name that you probably wouldn't think does a lot of programming. Training or coding help is what you will find here. A business that ends with "Shack" usually has the best and the most of whatever it sells...maybe. Check back often for coding tips, tricks, links, tutorials, and everything else.