Deserves its own post, even though I’m about to write the 0.11 one.
This release took much longer than I would have liked, mainly because I bit off more than I could chew. I had a requirement to provide poly-fills that implement query operations against in-memory datasets, on behalf of adapters for data-stores that don’t support certain operations. Think aggregates, grouping and so on. At some point, it occurred to me that this would make it really easy to create an in-memory adapter which would just have all query functionality implemented by these poly-fills.
Aside: From very early on, Simple.Data has had the XmlMockAdapter which could be used for providing a quick and dirty database for test environments. At the time I wrote that, I wasn’t totally confident in the Simple.Data model, so a way to instantiate that data without using the API seemed important. Since then, of course, the API has become much more stable and I’ve gained confidence, so it seems perfectly OK to use it to set up the test data as well as consume it. Consider XmlMockAdapter deprecated.
The InMemoryAdapter lives directly in the Simple.Data namespace in the Simple.Data.dll assembly from the Simple.Data.Core package. It is a first-class component, because testing is a first-class concern.
You can use the adapter like this:
Database.UseMockAdapter(new InMemoryAdapter()); var db = Database.Open(); db.Test.Insert(Id: 1, Name: "Alice"); var record = db.Test.FindById(1); Assert.IsNotNull(record); Assert.AreEqual(1, record.Id); Assert.AreEqual("Alice", record.Name);
That UseMockAdapter method is now directly on the Database class. After calling that, all subsequent calls to any of the Database.Open methods will return a database using that adapter.
Any tables you reference in the database will be “created” if they don’t already exist. Internally, the tables are just lists of dictionaries. Any data you insert will retain its CLR type, so the adapter can handle byte arrays and so on quite happily.
Joins are supported:
var adapter = new InMemoryAdapter(); adapter.ConfigureJoin("Customer", "ID", "Orders", "Order", "CustomerID", "Customer"); Database.UseMockAdapter(adapter); var db = Database.Open(); db.Customer.Insert(ID: 1, Name: "NASA"); db.Customer.Insert(ID: 2, Name: "ACME"); db.Order.Insert(ID: 1, CustomerID: 1, Date: new DateTime(1997, 1, 12)); db.Order.Insert(ID: 2, CustomerID: 2, Date: new DateTime(2001, 1, 1));
var customers = db.Customer
.FindAll(db.Customer.Orders.Date < new DateTime(1999, 12, 31)).ToList();
And most query operations work OK.
YMMV: This is probably not perfect, but it was stalling other development so I took the decision to release it. So far in my own projects it has not caused any problems; I’ve had one reported which is fixed in 0.11 (more on that in the next post).
Bug fixes and such
There were a bunch of fixes for various issues in 0.10, most of which were contributed by Richard Hopton, who has also released an ADO provider for Sybase SQL Anywhere.