technology from back to front

Archive for the ‘C#’ Category

Application-level change logging with EntityFramework

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.
Read more…

by
Martin Eden
on
22/04/13

Enums: not always the right tool

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?

Read more…

by
Frank Shearar
on
30/11/12

Downloading files with WebDriver

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.

Read more…

by
Martin Eden
on
11/06/12

ASP.Net MVC 2: mocking your HTTP layer

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.

Read more…

by
Frank Shearar
on
21/02/11

Search

Categories

You are currently browsing the archives for the C# category.

Feeds

Archives

2000-14 LShift Ltd, 1st Floor, Hoxton Point, 6 Rufus Street, London, N1 6PE, UK+44 (0)20 7729 7060   Contact us