The many approaches to Entity Framework

I recently had a need to look into using Entity Framework (EF) for a ASP.NET MVC project. In the past I have always used PetaPoco as my ORM of choice and with hearing nothing but bad things about EF I was a little sceptical. There are various ways to use EF, Code First being one of them and the easiest from what I can gather and luckily the approach I needed to get up to speed on. This means you can define your model in code and EF will turn that into tables in your database.

The way I was going to see how EF could be architected in an application was to create a MVC application that provided CRUD capabilities for Customers, Orders and Products. Nothing complicated but something enough to see how EF could be fitted in with a MVC application. I would also like to use a unit of work pattern such as instantiate a model class, set some properties and call a save method. I would also [...Read More...]

Abstracting the File System

Following on from my post about OSS I thought I would illustrate how cool OSS can be.

The day before that post was published I was working on a program that required the file system. All you good developers are going to know that the file system is a dependency and dependencies are bad and this post will probably be a bit like preaching to the choir however I thought it was worth posting.

So you have a a method similar to this:

1
2
3
4
5
6
7
8
9
10
11
public void DoSomethingCool()
{
  //do some stuff now write to file

  FileInfo f = new FileInfo("C:\\Mytext.txt")
  using(StreamWriter w = f.CreateText())
  {
    w.WriteLine("This blog post is cool");
    w.Close();
  }
}

You are [...Read More...]