Massive is a tiny, single-file, data access wrapper around SQL Server. It makes heavy use of System.Dynamic which means that it’s very flexible. It’s really a wrapper which does not get in your way. No extra assemblies, just as single file which you can drop in your solution.
Since Massive is SQL Server only and I work with MySQL, I’ve forked it to add MySQL support.
You can find the repository over at GitHub. There is also a NuGet package available, named Massive.MySQL which has MySQL.Data as a dependency. This means that you only need to do the following to get a working data access wrapper:
Install-Package Massive.MySQL
This will download Massive.MySQL, add it to your project, and download MySQL.Data (which is the only dependency).
I’m quoting the original readme for usage:
Let’s say we have a table named “Products”. You create a class like this:
public class Products:DynamicModel { public Products() : base("northwind") { PrimaryKeyField = "ProductID"; } }
Now you can query thus:
var table = new Products(); //grab all the products var products = table.All(); //just grab from category 4. This uses named parameters var productsFour = table.All(columns: "ProductName as Name", where: "WHERE categoryID=@0",args: 4);
You can also run ad-hoc queries as needed:
var result = tbl.Query("SELECT * FROM Categories");
Of course, Massive also supports updates and inserts:
var table = new Products(); var poopy = new {ProductName = "Chicken Fingers"}; //update Product with ProductID = 12 to have a ProductName of "Chicken Fingers" table.Update(poopy, 12);
//pretend we have a class like Products but it's called Categories var table = new Categories(); //do it up - the new ID will be returned from the query var newID = table.Insert(new {CategoryName = "Buck Fify Stuff", Description = "Things I like"});
For more information, please see the README file.
Thank you Rob for your efforts put into this, it’s a great tool.