Fork me on GitHub

Simple.Data

Simple.Data is a lightweight framework that uses the dynamic features of .NET 4 to provide an expressive, ORM-ish way of accessing and manipulating data without any of the code pre-generation and boilerplate required by other frameworks.

Click here to lend your support to: Simple.Data and make a donation at www.pledgie.com !

Index

Use the index below to find the information you require.

Getting Started

Retrieving Data

Commands that retrieve multiple results as a SimpleQuery object.

Commands that return a single result as a SimpleRecord object

Commands that return a single scalar result

Query modifiers

Table Joins

Aggregate Functions

Helper Functions

  • String length : Length (new)
  • Casting to Scalar values
    ToScalar, ToScalarList, ToScalarArray, ToScalarOrDefault
  • Casting to objects
    Implicit Casting, Cast<T>, ToList, ToList<T>, ToArray, ToArray<T>
  • Paging functions
    Skip, Take, WithTotalCount (forthcoming)
  • LINQ-like functions
    First, FirstOrDefault, Single, SingleOrDefault(forthcoming)

Modifying Data

Testing Your Code

Simple.Data provides the InMemoryAdapter for unit testing

Further Tasks

About

Simple.Data offers you the opportunity to code against many databases in more IDEs, so for the purposes of this documentation the following choices have been made

  • IDE : Visual Studio 2010
  • Server : SQL Server 2008
  • Database : MVCMusicStore
  • Language : C#

Sample Code

All samples in this documentation are part of the Simple.Data.Sample package which you can download as a NuGet package or from github at https://github.com/markrendle/Simple.Data.Sample

Sample Database

MVCMusicStore is part of an open source ASP.NET MVC project created by the ASP.NET team. You can find the complete project on Codeplex. Thanks to Jon Galloway for letting us use it.

MVC Music Store DB Schema

Additional Resources

There are several places to check for information about Simple.Data

  • Mark’s github page contains the project for Simple.Data.Core, as well as all the providers for various DBs, the sample code and the source for this documentation
  • The Simple.Data Google group is the place to ask for help and discussion
  • Mark’s blog is the place to learn about new developments in Simple.Data
  • This documentation site will continue to be updated via its github project. Please fork it and contribute

Simple.Data.Pad

Simple.Data.Pad (download here) is a GUI tool a bit like LINQPad, except it only works with Simple.Data. To use it, extract it from its zip archive onto a local disk, and run Simple.Data.Pad.exe.

The drop-down at the top left lets you choose an Open... method, and you can enter the parameters in the text boxes that appear when you've chosen one. Simple.Data.Pad comes with the SqlServer assembly, but you can drop any of the other adapter or provider assemblies in the app folder and it should pick them up.

To run a query, type it into the big text box. As you type, you should get an autocomplete box showing you available methods and properties, generated from the schema of the database you’re connected to.

Press F5 to run queries.

The Trace tab should show the SQL that was run against the database for the most recent query.

v1.0.0.0 is in no way anywhere near production quality. In particular, it doesn’t handle exceptions yet. It won’t kill you, though, or do bad things to your database, although stick to data retrieval queries for the time being.

Credits

Simple.Data was created by Mark Rendle (http://blog.markrendle.net/)

Six plug-ins have been additionally created

Documentation collated and written by Dan Maharry (http://about.me/danmaharry)