Posts Tagged ‘.net’

Binary trees in C#

June 24, 2011 Leave a comment

Great C# implementation of a binary tree by Roni Schuetz.

As simple to use as this:

    var x = new BinaryTree<int>();

Or this:

    var y = new BinaryTree<Taxicab>();
    y.Add(new Taxicab() { number = 3 });
    y.Add(new Taxicab() { number = 1729 });

    class Taxicab:IComparable<Taxicab>
        public int number { get; set; }
        public int frequency { get; set; }
        public int CompareTo(Taxicab other)
            if (this.number < other.number)
                return -1;
            else if (this.number == other.number)
                return 0;
                return 1;


Performance of in-line SQL vs. stored procedures

May 27, 2011 Leave a comment

Just been doing some load tests with .NET code against SQL Server 2008 R2 Developer edition via Data Access Application Block in Enterprise Library.

I insert 5,000 records into a table with a primary key on an Identity column and a clustered index on the same.  I’m setting 3 nvarchar fields and one smallint one, and then returning the Identity value of the newly added record.  The in-line SQL method calls SELECT SCOPE_IDENTITY() as the second statement in the batch and utilizes the ExecuteScalar() method while the stored proc path merely returns the same value and is called via the ExecuteNonQuery method.  Using caching as detailed below, I almost achieve 1,000 records per second on my developer machine.

I’m afraid I can’t help the stored procedure vs. in-line SQL debate as sometimes the in-line SQL is quicker and other times the stored proc is quicker!

However to get the greatest throughput (on both in-line and stored procs) be sure to cache (or reuse) the following:

  • Database object (from DatabaseFactory.CreateDatabase) – although caching this didn’t make a huge difference
  • DbCommand (needed for next item!)
  • ALL DbParameters – merely overwrite the values on subsequent calls instead of calling Database.AddInParameter


Minimum configuration for data access block v5

May 27, 2011 1 comment

If you’re using the Data Access Block from Microsoft’s Enterprise Library (v5, e.g. 5.0.414.0), here is the minimum configuration you’ll need to be able to do data access:



<sectionname=dataConfigurationtype=Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35requirePermission=true />





<addname=myDbConnconnectionString=data source=(local);Integrated Security= SSPI;Initial Catalog=myDatabase;providerName=System.Data.SqlClient/>



Without this you’re liable to get the error: “The type Database cannot be constructed. You must configure the container to supply this value.”


.NET Framework 4 Platform Update 1

May 19, 2011 Leave a comment

.NET Framework 4 Platform Update 1 was released a month ago.  Details on the new features are here in KB 2478063.

The updates are all around Workflow Foundation (WF):

  • Windows Workflow Foundation 4 State Machine Activity
  • SQL WF4 Instance Store (SWIS) on SQL Azure
  • Enable custom workflow hosts to use WF4 compensation

Note that there are several downloads.  You’ll need a separate one for Visual Studio 2010 design time support.

Steve Danielson describes the update in detail here.

Ron Jacobs notes what might be a bug here.


Categories: .NET, Visual Studio, WF Tags: , , ,

Study resources for MCPD Web Developer 4

May 16, 2011 Leave a comment

Here’s a list of resources you can utilize as you prepare for your MCPD Web Developer 4 certification.

The four exams you must pass are:

So first off, peruse the Skills Measured page for each exam (pages hyperlinked above).

If you’re into big reference books, here’s a link to each Self-Paced Training Kit (two have, two don’t):

My personal favourite are the practice tests:

If you already know WCF prior to .NET 4, this video will “upgrade” you”

Hope this helps.  Hit me up if I can help you hunt down some more resources.