Simple.Data 0.7

Feature complete!

I am very, very happy to announce that, with the latest release of Simple.Data – 0.7.1 – to NuGet, it is essentially feature-complete, at least as far as my personal road-map for it is concerned. There are still a couple of things to implement which will help adapter authors out, but for end-user-developers, it covers most of the things we need from a data-access framework. That is not to say I am not open to feature requests, particularly those that are for blatantly obvious things which I have half-wittedly omitted. The 0.7 series of releases will focus on improving performance, tidying up some of the code, and improving test coverage to catch any naughty bugs that are hiding out in there. The last release in the 0.7 series will effectively be the final 1.0 Release Candidate.

Before I embark on this final stretch, I’m going to take some time to create proper documentation so that all you lovely people out there can really put Simple.Data through its paces. Because of the dynamic nature of the framework, it lacks the discoverability that most .NET libraries get through IntelliSense, so it’s important to have some good quality docs to make up for that. I’m going to try and use Github’s wiki facility to build and maintain, particularly because community contribution would be greatly appreciated, but if that comes up short in any way, I’ll look for a better solution.

Anyway, never mind all that:

What’s new in 0.7.1?

There’s a fair selection of new features in this release, and one breaking change which I’ll get out of the way first:

Count and CountBy are now GetCount and GetCountBy

In order to support the Count operator within queries, I’ve had to change the name of the Count methods on the table object, so these are now called GetCount and GetCountBy:

db.Posts.GetCount(db.Posts.Rating >= 4);

“Having” clause support

Queries now support a Having method, which represents the clause of the same name in SQL selects. You can use all the aggregate methods that are supported in column selection lists: Min, Max, Avg, Sum and Count.

// Find all posts without comments
db.Posts.All().Having(db.Posts.Comments.CommentId.Count() == 0);

Math operators

Expressions can now include simple mathematical operators: add, subtract, multiple, divide and modulo.

// Find all animals with an odd number of legs
db.Animals.Find(db.Animals.LegCount % 2 == 1);

Bulk Inserts and Updates

You can now pass lists (or IEnumerables) of dynamically- or statically-typed objects to the Insert, Update and UpdateBy methods. In the case of Insert, when using the Ado adapter, you get back a new list of objects with any database-assigned default values such as identity values or timestamps. The Update methods just return a count at the moment, but I might change that to return the updated records.

(One thing that definitely may be a possibility by 1.0 is an Upsert method, which would take a list of objects, insert the new ones and update the existing ones.)


Guids are once again supported for SQL Server’s “uniqueidentifier” type, and probably the equivalents in the other supported ADO databases.

A null-equality expression in Simple.Data criteria will become an “IS NULL” expression in the SQL generated by the ADO adapter.

Various other glitches and peccadilloes have been spotted and terminated with extreme prejudice. However, I have reason to believe that there may be more glitches, and even another peccadillo or two, at large in the code. If you encounter one, please either fork the code, kill the creature and send me a pull request, or, if it’s particularly fierce and you don’t want to get near its teeth, just open an issue on Github with some sample code that will draw it out into the open so I can shoot it.

Go for it

At this point, I am happy to recommend that you can use Simple.Data in production systems. Many people are already, with no reported problems. Obviously your mileage may vary, but I am confident that any speed-bumps or potholes (or rogue metaphors) that you run across will be relatively minor and easy-to-fix (except the metaphors, which are tenacious and systemic).

I’ll post here again once I’ve made a start on some comprehensive documentation. In the meantime, if you need any help, the first place to try is the Google group/mailing list; the second is the Github site, and the third is either me on Twitter or, potentially, the creator of your particular adapter or Ado provider.


  1. Awesome!

  2. Great job 🙂 Cant wait for the documentation. That missing intellisense is driving me crazy 🙂
    btw how can be used in I mean, when using nhibernate you have to take care of open sessions/transactions…how do you do it when you use there is no thing like session/transaction?
    And second question. Can I somehow view what sql commands executes? I would like to see what sql queries it generetas.


    • Libor:

      Simple.Data doesn’t hold a context in the way that NH or EF do. It opens a connection when it talks to the database, and closes it as soon as it is finished. So you don’t need to worry about sessions or anything.

      The Ado adapter writes all the generated SQL to the Trace, so if you have a TraceListener attached you’ll be able to see them; if you’re running in VS in Debug mode they’ll be in the Output window.


      • thanks, so why is so fast compared to linq2sql/EF even tho it opens and closes connection for every sql query?

        • I’m not entirely sure why EF is so slow, but I suspect it is something to do with all the change-tracking and stuff that it does. Opening and closing connections is not an expensive operation, at least for SqlClient, since it creates a pool of connections with all the expensive complicated stuff done up front, and then assigns them from that pool, so the setup and teardown is minimal. I think the same is true for most other RDBMS engines and their ADO providers, although not for SQL Compact, but creating connections is less expensive there.

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: