Simple.Data is out there

On Friday the 21st of January, 2011, I pushed Simple.Data up to NuGet for the first time. (Actually there was a push before that, but it was premature, so I’m pretending it didn’t happen.)

On Saturday the 22nd I got my first bug report, and on the 23rd I fixed it and pushed an update, version 0.4.5.

Then I started writing this blog post. In between then and now, I’ve done a presentation at DDD9 where I had Jon Skeet in the audience, and done a podcast with the guys at Herding Code, and things have generally been a bit mental and awesome in equal measure.

Anyway, I’ve just pushed another update, 0.4.6, which addresses a performance issue with creating arbitrary numbers of dictionaries to represent rows.

So I thought I’d post a quick overview of where it’s at right now, on version 0.4.6.

This is the first I’ve heard of Simple.Data. What is it?

It’s a database access library built on the foundations of the dynamic keyword and components in .NET 4.0.

It’s not an O/RM. It looks a bit like one, but it doesn’t need objects, it doesn’t need a relational database, and it doesn’t need any mapping configuration. So it’s an O/RM without the O or the R or the M. So it’s just a /.

I think it’s ideal for smaller projects on platforms like WebMatrix or Nancy, where something like Entity Framework or NHibernate would be overkill, but you still don’t want to have to type a bunch of crufty SQL and the associated ADO.NET boilerplate.

Also, it makes it impossible to create database code which is vulnerable to SQL Injection attacks. If you don’t know what that means, then you need to use Simple.Data.

Current features

At the moment, Simple.Data provides support for the most basic find operations using the FindBy* and FindAllBy* dynamic methods, which generate straight equality conditions at the database. These also support lists, which produce an IN clause, and a Range type, which produces a between.

For more complex criteria, there are the Find and FindAll methods which take an expression, so you can do inequality operators, plus use a Like method on strings. They also support joins across tables where there is referential integrity defined in the DB.

Then there are the Insert, Update and Delete methods, which do those things. Insert and Update have versions which take entire dynamic or static objects, or you can use named parameters.

There’s basic support for master-detail relationships built into the dynamic records, again, as long as you have the primary and foreign keys defined.

And for those scenarios where you just can’t do something in Simple.Data itself, there’s Stored Procedure support for SQL Server databases.

Full details on all the syntax is on the wiki.

Supported Databases

The code has been tested on SQL Server 2008 and 2008 R2, and SQL Server Compact 4.0. I have decided to drop the support for SQL Server Compact 3.5 as I don’t expect there to be much demand for the legacy support and I don’t want to waste cycles that are better spent adding features.

Pretty high on my list of priorities is support for the 3 main OSS databases: MySQL, PostgreSQL, and SQLite.

Because Simple.Data has a very flexible adapter model underneath, it’s possible to get it talking to non-RDBMS data sources. I spiked something that worked against the Windows Registry, although I only did that to see if I could. It’s not something I’d recommend. But I have got the ground-work in place to get it working with Windows Azure Table Storage, which will be cool.

Getting it

Currently the best way to get Simple.Data into your project is using the NuGet package manager. I’m working on adding native OpenWrap support, but it’s lower priority since OpenWrap can use the NuGet repository.

Available resources

If you need some help with something, I’ve created a Google Group for discussion, so post on that. I get the emails straight away, so you should get a reasonably quick response.

If you think something is broken, or you’ve got a burning need for a feature, then open an issue on the Github project page.

Things that need doing

I’m working on 0.6 features, which are as described in this earlier post, but there are a few other things that need doing if you’re looking for something to hack on. The single most important of these is getting the project building on Mono, so if you fancy doing that, please pull the code and let me know what stops it from working. Obviously getting the additional databases supported would be a bonus for that scenario too, so if you want to try writing a provider for one of those, give me a shout and I can remote-pair with you to get you started.

Trackbacks

  1. […] Simple.Data is out there – Mark Rendle announces the first release of Simple.Data, a data access library which makes heavy use of .NET 4’s support for dynamic types, providing a simple way to do data access in platforms like WebMatrix and Nancy. […]

  2. […] addition, to see Simple.Data in action was very useful.  I have heard @stack72 say a lot of good things about it, but I had […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: