SQL Server, Analytics, .Net, Machine Learning, R, Python
Mitch Wheat has been working as a professional programmer since 1984, graduating with a honours degree in Mathematics from Warwick University, UK in 1986. He moved to Perth in 1995, having worked in software houses in London and Rotterdam. He has worked in the areas of mining, electronics, research, defence, financial, GIS, telecommunications, engineering, and information management. Mitch has worked mainly with Microsoft technologies (since Windows version 3.0) but has also used UNIX. He holds the following Microsoft certifications: MCPD (Web and Windows) using C# and SQL Server MCITP (Admin and Developer). His preferred development environment is C#, .Net Framework and SQL Server. Mitch has worked as an independent consultant for the last 10 years, and is currently involved with helping teams improve their Software Development Life Cycle. His areas of special interest lie in performance tuning
Friday, May 28, 2010
Using SMO to Create an Index with Included Columns
A question that came up on the SqlDownUnder mailing list today was how to create an index using SMO and specify an included column. The documentation is extremely scarce; I could find no mention of it in MSDN. Greg Low came to the rescue by noting that the IndexedColumn class has an IsIncluded property.
This is illustrated in the following C# snippet:
public Index CreateIndex
string indexColumnList, // in index column order
if (indexDescending != null && indexDescending.Length != indexColumnList.Length)
throw new ArgumentOutOfRangeException(
"Either pass indexDescending as null, or with same length as indexColumnList.");
Index index = new Index
Name = indexName,
IndexKeyType = indexKeyType,
IsClustered = isClustered
int i = 0;
foreach (string indexColumnName in indexColumnList)
bool descending = (indexDescending != null) ? indexDescending[i] : false;
IndexedColumn indexedColumn = new IndexedColumn(index, indexColumnName, descending);
// Only add included columns for none primary or unique indexes
if (includedColumnList != null && indexKeyType == IndexKeyType.None)
foreach (string includedColumnName in includedColumnList)
IndexedColumn indexedColumn = new IndexedColumn(index, includedColumnName);
indexedColumn.IsIncluded = true;
Thursday, May 27, 2010
Reminder: Perth .NET User Group Meeting: Thurs 27th May, 5:30pm: XNA Game Development - with Andrew Parsons
Join us at the Perth .NET User Group Thurs, May 27th where Andrew Parsons will build a simple 2D shooter game for Windows and Xbox 360 in an hour from start to finish, and hear how you can do the same thing with the tools already at your disposal not just for Windows and Xbox but also the upcoming Windows Phone 7.
Andrew Parsons is the Academic Developer Evangelist for Microsoft Australia which means he gets to travel the country talking to students about cool technology - stuff like Xbox, Windows Phone, cool dev stuff, tips and tricks with Office, PhotoSynth, Pivot and more. Combining his 15 years as a professional developer and 8 years as a professional games journalist prior to joining Microsoft, his passion for video game development has seen an outlet through XNA.
Tuesday, May 18, 2010
Using CopySourceAsHTML 3.0 with VS 2010
Update: although this works, it makes VS2010 open really slowly...
There does not seem to be an installer for VS2010. You can install the VS2008 version of CopySourceAsHtml (from here), and then manually edit the CopySourceAsHtml.AddIn file located at C:\Users\<username>\Documents\Visual Studio 2010\Addins so that both Version elements are set to 10.0:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Name>Microsoft Visual Studio Macros</Name>
<Name>Microsoft Visual Studio</Name>
<Description>Adds support to Microsoft Visual Studio 2008 for copying source code, syntax highlighting, and line numbers as HTML.</Description>
<Assembly>JTLeigh.Tools.Development.CopySourceAsHtml, Version=3.0.3215.1, Culture=neutral, PublicKeyToken=bb2a58bdc03d2e14, processorArchitecture=MSIL</Assembly>
Recursively Enumerate Files
I recently needed to get all files in a folder hierarchy, so I quickly wrote the following C# snippet:
List<string> files = FindMatchingFilesRecurse(startFolder, "*.txt");
public List<string> FindMatchingFilesRecurse(string folder, string filePattern)
List<string> fileList = new List<string>();
FindMatchingFilesHelper(folder, filePattern, fileList);
private void FindMatchingFilesHelper(string folder, string filePattern, List<string> list)
foreach (string dir in Directory.GetDirectories(folder))
FindMatchingFilesHelper(dir, filePattern, list);
But .NET 4.0 now contains the same functionality in a single method call (and as a bonus, it’s approximately 20-30% faster!):
List<string> files = Directory.EnumerateFiles(startFolder, "*.txt", SearchOption.AllDirectories).ToList();
Sunday, May 09, 2010
Connect to SQL Server Using Windows Authentication
In a recent post, Securing your application. Part 1 - Securing your connection, Brian Madsen talks about encrypting your database connection string, but fails to mention that using this technique does not stop passing unencrypted passwords over the network to your database server.
Whenever possible, you should use Windows authentication instead of SQL authentication to connect from your ASP.NET application to your database server. You should still consider encrypting your connection string to protect server connection details, such as the server and database name.
Sunday, May 02, 2010
Perth .NET User Group Meeting: Code Contracts in Framework 4.0 with Joe Albahari
Join us at the Perth .NET User Group Thurs, May 6th for a presentation on Code Contracts. With Framework 4.0, Code Contracts are now a reality. In this session, we'll look first at what Code Contracts are, and then demonstrate how to use them in Framework 4.0 to write more robust, concise and better-documented code. We'll also look under the covers on how they work, and see how to tailor contract behaviour for development, deployment, legacy and unit testing environments.
Joe Albahari is author of O'Reilly's C# 4.0 in a Nutshell. He's a regular user group speaker and has presented at TechEd and JAOO.
There will be door prizes of: 2 copies of 'C# 4.0 in a Nutshell' and a LINQPad license courtesy of Joe Albahari, plus a choice of license from JetBrains (one of ReSharper , TeamCity Build Agent, dotTrace Profiler, RubyMine, IntelliJ IDEA).
Arrive early if you want a seat!
MSN, Email: mitch døt wheat at gmail.com