Saturday, September 02, 2006

My First Blog

Can you believe it? I am such a geek and yet, until now, had not fallen for the blog craze. I created this one on a whim this morning. We'll see how well I keep it up.


UPDATE: This was added long after (several years!!): I’m using this post to test some code snippet plug-ins. This post can certainly be ignored!
public void SetParmDirection(string ParmName, ParameterDirection direction)
{
    if (ParmName.StartsWith("@") == false)
        ParmName = "@" + ParmName;

    if (this.oCommand.Parameters.IndexOf(ParmName) > -1)
        this.oCommand.Parameters[ParmName].Direction = direction;
}
Another plug-in:
public void SetParmDirection(string ParmName, ParameterDirection direction)
{
    if (ParmName.StartsWith("@") == false)
        ParmName = "@" + ParmName;

    if (this.oCommand.Parameters.IndexOf(ParmName) > -1)
        this.oCommand.Parameters[ParmName].Direction = direction;
}
And now I’m going to test a combination of the two. This is tricky in that I have to steal the div tags from the first plug-in and wrap them around the html from the second plug-in … making sure to change the ids as well. Let’s see if this works well or not:
// ds20 is a 2.0 Typed DataSet, which uses plain a plain old DataTable

DataTable dt20 = ds20.Personnel.DefaultView.ToTable(true);

DataTable dtLinq = ds20.Personnel.AsEnumerable()
    .Select(row => row).Distinct(DataRowComparer.Default)
    .CopyToDataTable();
// Note that if you MUST use the DataRowComparer.
// If you don't you get all rows returned ... it won't find the duplicates.
And another:
// ds35 is the 3.5 Typed DataSet
// note that the only difference in syntax is that you don't need .AsEnumerable()
DataTable dt35 = ds35.Personnel.Select(row => row).Distinct(DataRowComparer.Default).CopyToDataTable();
OK … so it displays fine in my editor. Let’s publish it now to the blog and make sure it’s still OK.
UPDATE: Darn, a new version of Live Writer, now I need all new code snippet plug-ins!
// ds20 is a 2.0 Typed DataSet, which uses plain a plain old DataTable

DataTable dt20 = ds20.Personnel.DefaultView.ToTable(true);

DataTable dtLinq = ds20.Personnel.AsEnumerable()
    .Select(row => row).Distinct(DataRowComparer.Default)
    .CopyToDataTable();
// Note that if you MUST use the DataRowComparer.
// If you don't you get all rows returned ... it won't find the duplicates.

Well, it’s almost as good as my old plug-in … except it doesn’t get its syntax coloring directly from Visual Studio, so classes, such as DataTable, aren’t colorized correctly. But, I guess I can live with it for now …
UPDATE: Just checking that WLW (Live Writer) isn’t broken anymore.