My Projects

Recent Posts

A year ago I had written briefly about my love-affair with the yield keyword. Today a question was posed to me and the follow-up discussion was interesting enough to me to warrant a quick post. If you're returning an IEnumberable<T> from a method that reads from a DataReader, is it bad to use yield? My concern is calling a long-running method while looping over the items returned from the method – won’t this keep the SQL connection open longer? Also what if an exception happens while looping, will my reader still get closed? His...

A common requirement for many applications is filtering rows of data based on the current user. A simple example is an e-commerce site which would want to make sure a Customer who is logged in is only able to view his own Orders. Another example would be a payroll site that would want to make sure a user could only view their own Employees. These are of course trivial examples, and could be solved in a number of ways. My concern is that often times the responsibility of security is placed upon each individual developer to make sure they...

Below is a preview of my Windows Phone 7 app used for real-time tracking of Chicago buses. This app will make sure you never miss a bus, and perhaps more importantly, will make sure you know the best time to leave your house or office so you don’t end up standing and waiting at the bus stop for a ridiculous amount of time. It takes full advantage of the Bing Maps Silverlight control to plot out exact GPS locations of buses and stops, making sure you always know the optimal time to leave. ...

Long story short, I have been struggling with a very frustrating Visual Studio 2010 bug since last Monday. All of a sudden, VS was hanging and eventually crashing every time I loaded my solution. After a while, I finally noticed something in the Server Explorer window… If you look closely at the screenshot below, you will notice that every node in my database says “[Expanding…]” after it – but it’s actually worse than that. In fact, every single database connection (I had 8 in my server explorer), is trying to open itself, and expand every single table, column, stored...

This post is part of a series on customizing the Entity Framework T4 templates I have been using EF4 for a little while now, and have been taking advantage of the code-generation extensibility afforded to us by T4 templates. This series of posts will describe the enhancements I have made to the default T4 template, and how you can take advantage of this functionality yourself. Part 1 – Generate an IDatabase interface to represent your Data Context Part 2 -...

I will be giving a talk at the Chicago Architects Group on Onion Architecture next week, details below. This is a completely free event, and of course, pizza will be provided. When Tuesday, April 20, 2010 from 5:00 PM - 8:00 PM (CT) Where TechNexus 200 S Wacker Drive Suite 1500 Chicago, IL 60606 Abstract Onion Architecture by Matt Hidinger Onion architecture exploits well-known patterns like dependency injection to promote true loose coupling between the core business logic and technical implementation details of an application.  Join us as we discuss this approach to building robust applications. Followed by open forum   CAG site: http://chicagoarchitectsgroup.com/ Registration: http://chicagoarchitectsgroup.eventbrite.com/   Technorati Tags: presentations,architecture

Hopefully I didn’t completely miss the boat… People are still on twitter right? I heard rumors that everyone left and moved to foursquare? Technology is enough to make people of any age feel old. http://twitter.com/matthidinger

Starting back in 2007 I read a series on Co/contra-variance in C# by Eric Lippert – Eric is on the compiler team at MS and one of my favorite bloggers to read I might add. At the time, I remember myself reading along with the words but my eyes completely glazing over. To be honest the concept mostly eluded me at the time, so I wanted to take this opportunity to describe the feature in a way that made the most sense to me. It Seems to Logical… Ask yourself the following questions: ...

I’m going to assume that most of you reading my blog are passionate about software and do some developing in your spare time. If you’re a consultant, you probably do most of your work on a laptop -- perhaps using the same laptop for office and hobbyist development. Others among you might have a laptop and a desktop, or maybe you’re like me and have a laptop and multiple desktops. All with Visual Studio and ReSharper on them – of course. About 2 years ago I got really big into ReSharper Live Templates – I started writing them for...

On the surface, I suppose this is YAMVCVWFC (Yet Another MVC vs. WebForms Comparison). If this topic doesn’t appeal to you, or you’re sick and tired of this discussion then I encourage you to move on. I won’t be offended, promise. This post is here to serve as my living, breathing arguments for fighting for MVC and it will serve to highlight my major gripes with Web Forms. The motivation for this post came from an all-too-familiar IRC chat in #asp.net – for those of you unfamiliar with IRC, it’s a lot like the Twitter of the 90s....

I saw the following question asked earlier today -- the only context given was the code itself. Can anyone tell me what’s wrong with this Dim min As Integer = Integer.Parse(leavingTimeTextBox.Text.Substring(leavingTimeTextBox.Text.IndexOf(":") + 1, leavingTimeTextBox.Text.Length) -1 )? it shows me an exception index out of range exception: length and index must be within the range of the string, parameter name: length  so its five characters and on debug time : index is 2 so I'm starting from index 3 to length which is 5 -1 "4" It was clear that he looking to parse some sort of pre-defined time format, but...

As a brief recap, the reason this post even exists is because the generated code from the EF4 designer does not properly suppress code analysis warnings. In that post, I mentioned that I would provide a proper T4 template and tutorial on integrating it into your EDMX model. This post details the steps to creating and customizing an Entity Framework 4 T4 template. T4 (the Text Template Transformation Toolkit) is the code generation technology built into Visual Studio. Thankfully, the EF4 designer has been enhanced to support customizable templates so that developers are free to change the code...

Update I have published the instructions and provided a template that can be used to properly suppress code analysis.   Starting a new project opens the doors for some great things. One of those things for me, was adherence to code analysis from the get-go. Visual Studio 2010 in particular has great Code Analysis Rule Set support allowing teams to carefully dictate which rules they wish to apply and suppress. Unfortunately, it wasn’t long before the decision to use Entity Framework 4 put a nice little wrench in my code analysis plan. (As an aside, I will blog more about my decision to use...

A very welcomed addition to the all-too-common File In Use dialog when trying to delete a file that a process has locked. As you can see from the screenshot, the dialog in Windows 7 finally tells the user exactly which process is preventing the deletion. No longer do I need Process Monitor from SysInternals for such a simple need.   Technorati Tags: Windows7

Unable to update the EntitySet 'PlanPriceHistory' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation. While I was getting my feet wet in Entity Framework 4 (from the Visual Studio 2010 Beta 2 release), I generated my EDMX from an existing legacy database. All was going well – for a few days in fact, until I attempted to Insert an entity to a specific table (seen below). After some digging around in my model/EDMX configuration thinking something was wrong in there, I decided to open...

Unit testing a method that relies on DateTime.Now is generally a challenge. Take the below example, which was the first version of a method to get the Current Price of a Product. The business rule for GetCurrentPrice() is simple: find the most recent price where the effective date is not in the future. For this scenario, imagine the user sets the Price of a product to $25,000 but that price doesn't take effect until the next year. Until that time, we must make sure that the system returns the previous (existing) price. The poorly testable method public decimal GetCurrentPrice() { ...

Researching strategies for unit testing view model mappers… It never occurred to try google.com to find that information…

As is usually the case when I encounter a pain point while developing with Visual Studio, a quick google search reminds me that all along this problem has been solved for me. Today’s lesson is brought to you by the all-to-common namespace renaming. Earlier today I started cleaning up the file structure in the Solution Explorer, and up until now I would resort to a clumsy Solution Wide Find-Replace to fix up the namespaces after the files were moved into their more logical placement. However, I should have realized that ReSharper would have handled this for me – and...

This post was spawned as I was reviewing the latest Oxite source code on CodePlex. I’ve been reading any source code I could get my hands on lately looking for inspiration to cure my “winter coding boredom.” While it isn’t winter yet, it is fast approaching, which means less outdoors time and more computer time. I try to blog more, update my open source projects with a new release, and with any luck begin a new project worth getting passionate about. Today I'm going to hit the ground running with a short tip, again, on the yield keyword. The following code...

Today I began integration testing my SqlRepository while I experiment with an MVC prototype. I tried googling for a simple base class for integration testing a LINQ to SQL DataContext that would provide automatic rollback between each test, but after (minimal) searching, decided to simply write my own. Perhaps this will help someone. This base class was written for MS Test, but simply renaming the attributes accordingly would yield the same results on nUnit, xUnit, etc. The Code Simply inherit your test class from this base class and any changes done via the internal Context property will be...