RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


The Baker's Dozen: 13 Miscellaneous C#, SQL, and Business Intelligence Development Tips

Windows Communication Foundation is one of the most important features in the history of .NET. Not only does WCF provide a unified programming model for communications, it also promotes the use of interfaces and various recommended programming practices.

o, the title isn't a misprint—this installment of the Baker's Dozen will visit both sides of the planet.

These days, many .NET user group meetings focus on database and business intelligence topics as well as hardcore .NET content. Over the last several months, I've spent roughly half my time modifying my own development framework for WCF. The result is some basic but functional factory classes I'd like to share. The other half of the time, I've been looking at different capabilities in the SQL Server 2005 and 2008 Business Intelligence stack, and solving requirements that BI developers often face. So rather than pick one side and make the other side wait two months, I decided to combine the two.


Recently I had a conversation with a highly-skilled .NET programmer about SQL Server Transaction Isolation Levels. While the entire conversation is too long to repeat, the person didn't seem very interested in talking about them. Not long after that, I had a talk with a DBA who had even less interest in talking about .NET assemblies designed for SQL Server.

Sure, individuals can't have an interest in everything—or should they? Consider this, an old baseball story about Willie Mays. Early in Mays' career, his manager, Leo Durocher, would ask Willie such questions as, "there's one out, you're on second base, there's a left-handed hitter at the plate who can't get around on the pitcher's fastballs…how long of a lead should you take?" Mays' reply was, "I don't need to know, that's for the manager to tell me, I'm the player." Durocher replied, "No, Willie, you need to know these things, and when you develop an understanding, it'll make you a better ballplayer."

OK, it's not practical to be an expert in everything—but in the Microsoft computing world, being a Jack (or Jill) of many disciplines will ultimately increase the value that you bring to the table. (And it doesn't preclude you from being a master at one or two.) For all the buzzwords that you hear every day, "value" is one to always keep in the front of your mind.

What's on the Menu?

This installment will start out with a set of C# tips for WCF, and then cover a few miscellaneous tips for using C# with both SQL Server and other tools in the Microsoft BI stack. Finally, we'll look at some powerful capabilities in the BI stack. So, here are the menu items for today!

The Baker's Dozen Spotlight:

  • Creating some basic WCF factory classes (in three parts)
  • Setting up SQL Server 2005 stored procedures as HTTP endpoints and then calling them from .NET
  • Executing SQL Server Integration Services (SSIS) packages from within .NET
  • Generating email dynamically from inside SSIS
  • Revisiting some basic productivity classes in C# for handling Crystal Reports.NET data
  • Reading a Microsoft Analysis Services OLAP database from C#
  • Defining roles in an OLAP/Analysis Services environment so that certain users/roles will see only certain dimension members (i.e. brand managers)
  • Building an OLAP date dimension and writing some MDX code to perform seasonal analysis of sales over the period of two Easter years
  • MDX Named Sets in SQL Server 2008
  • Searching data dynamically in SQL Server without using dynamic SQL
  • Using the PerformancePoint Service Web Service from .NET

Some Background for the First Three Tips…

Windows Communication Foundation (WCF) has been out for roughly two years now. Of all the new .NET features in the last few years, WCF is one of my favorites. I never enjoyed maintaining multiple code bases for .NET Remoting and web services, and even wrote some factory classes in the June/July 2005 issue of CoDe Magazine to provide a single model for different communication protocols. (In retrospect, those classes were a VERY poor man's WCF!)

Even though WCF may seem like "old news" to some, there are many developers who are still learning WCF. I have a community session (a beginner session) called "Crash Course on WCF Programming" that is well attended. Because so many developers are still seeking information to get started on WCF, I'll provide a brief walkthough of a solution in Tips 1-3.

However, I also want to provide some value to those who have been through the basics of WCF. So I'll provide a client-side factory class that you can use to avoid repeated WCF calls to ChannelFactory and CreateChannel. I'll also talk about some issues you may encounter when hosting WCF services over HTTP.

Editor's Note: This article was first published in the January/February 2009 issue of CoDe Magazine, and is reprinted here by permission.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date