We have been developing Daylight, which is a records management system for Freedom from Torture, a charity dedicated to the treatment and rehabilitation of survivors of torture. Due to the sensitive nature of the data being recorded, Freedom from Torture wanted a way of tracking every change that was made to records.
The application uses Entity Framework as an ORM layer over an SQL database. One option would have been to use database triggers to log changes. However, we wanted to track changes not in terms of the database model, but in terms of the application model. This allows us to then easily query the log at a later point using the same application model and make sense of it. We can directly re-hydrate the logs back into C# objects in different recorded states in a strongly typed manner.
The solution is to override the database context object’s SaveChanges method. However, inside that statement is quite a lot of complexity! I have spent some time over the last few weeks extracting the logging code from the client application and the result is FrameLog, an open source logging library for Entity Framework.
Enums are a way of encoding a set of ordinal values in a type system. That is, they formalise the notion that a value may be one of a small set of specific values. We’ve had them since at least the 1970s. They’re really useful. So why might they not always be the right tool?
We have been using WebDriver (/Selenium) for doing functional testing of web applications. I have personally been involved in using WebDriver on .NET to automate testing of several .NET web applications.Â But in my spare time, I’ve discovered another use for WebDriver, which is automating interactions with websites.
We recently started a project using Microsoft’s ASP.NET MVC 2Â framework. Since I’m pretty big on test driven development, IÂ immediately wanted to start unit testing the controllers. It turns outÂ that it’s a bit harder than I thought: in production, MVC does a wholeÂ bunch of stuff before execution ever reaches your controllers. And ifÂ you naively just start applying TDD, you get all sorts of funkyÂ NullReferenceExceptions deep in the bowels of MVC.
You are currently browsing the archives for the C# category.