Archive for the 'c#' Category

Sending the LINQ To SQL log to the debugger output window

I was playing with LINQ To SQL (again) this evening, and I thought: why can’t I see the generated SQL statments in my debugger output window?

The DataContext.Log property is a great help to learn writing LINQ To SQL queries. All you need to do is assign a TextWriter to it, and you get to see al the SQL statements generated by the data context. But where do you send them to? Console.Out is an option, but you probably don’t want that in a release build. Furthermore, it doesn’t quite work for Windows services or ASP.NET applications. That’s why I wrote DebuggerWriter, an implementation of TextWriter that writes to the debugger log.

Find the code at my U2U Blog.


Compiling Regular Expressions

Update your bookmarks, new posts on .NET related stuff will be posted to The first new one to appear there is all about compiling regular expressions in .NET, with a free compiler tool to download. Enjoy reading.

Linq to XSD preview released

Last Monday, the Microsoft XML Team released the first Linq to XSD preview.

While the LINQ to XML programmer operates on generic XML trees, the LINQ to XSD programmer operates on typed XML trees — instances of .NET types that model the XML types of a specific XML schema (XSD). […] LINQ to XSD is integrated into Visual Studio; so you just tag an XML schema as [a] ‘LINQ to XSD schema’, build your project, and the automatically derived object model is then part of your solution — just as if XML schemas were .NET types.

I only had a quick look, but I have to say it looks very promissing! Send them your feedback, but hurry, I want this to be included in Visual Studio Orcas.

Creating a Data Access Layer with Linq to SQL, part 2

Last time, we looked at how Linq To SQL might impact how we think about what a Data Access Layer (DAL) is, based on the dependencies between assemblies. This time, we’ll take a different approach: let’s look at typical Linq to SQL code, and try to decide where to put it. I’ll use a code sample from the “DLinq Overview for CSharp Developers” document included in the Linq May CTP (in C# 3.0, but the same applies to VB9).

Continue reading ‘Creating a Data Access Layer with Linq to SQL, part 2’

Amazing XAML

Since the .NET Framework 3.0 has been released, the interest is Windows Presentation Foundation (WPF) and XAML is growing. A good understanding of XAML and how it works is essential to understand WPF. A while back, Peter Himschoot wrote an excellent article about it: Amazing XAML.

Tools I use for C# development

I’m often asked what tools I recommend for (general) .NET development, or at least which tools I use on a regular basis. Here’s a list:

  • Visual Studio Team Suite. I you can’t get Team Suite, get the Professional version. If you can’t get that one, use the Express version.
  • Code Analysis, which is built into Visual Studio Team Suite. FxCop does the same thing, and is free to download.
  • .NET Reflector. After MSDN Help (and possibly Google), this tool delivers the best documentation on the .NET Framework. Another free download.
  • The unit testing framework that is built into Visual Studio Team Suite. If you don’t have Team Suite, NUnit is a very good, free alternative, possibly in combination with NCover. TestDriven.NET integrates them into Visual Studio. All Free.
  • If I need to edit graphics such as icons or other bitmaps, I use Paint.NET with some additional plug-ins installed. Free as well.
  • Hardly needed at home, but for team projects at U2U we use Team Foundation Server.

There definitively are some other tools I should take a look at, for example WiX, or SandCastle and the SandCastle Help File Builder.

I you know of any must-have tools I didn’t mention, drop a comment.

Properties with property changed event, part 2

Last time I talked about properties with a changed event, I described the traditional pattern of having one event per property. But there is a disadvantage to that approach: since an event needs storage for a delegate, this technique wastes a considerable amount of memory if nobody subscribes to the events.

Continue reading ‘Properties with property changed event, part 2’

RSS My U2U Blog

  • An error has occurred; the feed is probably down. Try again later.

RSS Top blogs linking to here

  • An error has occurred; the feed is probably down. Try again later.