Skip to content
This repository

A light-weight, dynamic data access component for C# 4.0

Merge pull request #327 from jplane/master

added support for dynamic indexer getter to SimpleRecord
latest commit 65ff01e482
Mark Rendle authored
Octocat-spinner-32 Assemblies Added SQL CLR assembly October 08, 2012
Octocat-spinner-32 PerformanceTestConsole Removed accidently added files January 08, 2013
Octocat-spinner-32 ProfilingApp Removed accidently added files January 08, 2013
Octocat-spinner-32 Releases Added NuGet folder January 21, 2011
Octocat-spinner-32 Simple.Data.AdapterApi Removed accidently added files January 08, 2013
Octocat-spinner-32 Simple.Data.Ado.Test Removed accidently added files January 08, 2013
Octocat-spinner-32 Simple.Data.Ado Adding Schema Support December 30, 2013
Octocat-spinner-32 Simple.Data.BehaviourTest Fixes #291 May 21, 2013
Octocat-spinner-32 Simple.Data.InMemoryTest Merge pull request #329 from sandranystrom/master March 31, 2014
Octocat-spinner-32 Simple.Data.Mocking.Test Removed accidently added files January 08, 2013
Octocat-spinner-32 Simple.Data.Mocking Fixed tests that use Trace listener May 21, 2013
Octocat-spinner-32 Simple.Data.SqlCe35 Improving SQL CE 4.0 support January 20, 2011
Octocat-spinner-32 Simple.Data.SqlCe35Test Added NUnit as a NuGet package January 20, 2011
Octocat-spinner-32 Simple.Data.SqlCe40 Misc exception messages improved (AE, ANE, IOE), ensured stack trace … April 08, 2013
Octocat-spinner-32 Simple.Data.SqlCe40Test Removed accidently added files January 08, 2013
Octocat-spinner-32 Simple.Data.SqlServer Fixes issue #338. (SqlBulkInserter breaks when the records given to i… March 25, 2014
Octocat-spinner-32 Simple.Data.SqlTest Fixes issue #338. (SqlBulkInserter breaks when the records given to i… March 25, 2014
Octocat-spinner-32 Simple.Data.TestHelper Removed accidently added files January 08, 2013
Octocat-spinner-32 Simple.Data.UnitTest added support for dynamic indexer getter to SimpleRecord January 15, 2014
Octocat-spinner-32 Simple.Data Merge pull request #327 from jplane/master March 31, 2014
Octocat-spinner-32 packages Fixed problem with ConcreteTypeCreator in Medium Trust August 29, 2012
Octocat-spinner-32 .gitignore Merged from Athari pull request May 10, 2013
Octocat-spinner-32 AutoTest.config Nuget release 0.10.1 November 21, 2011
Octocat-spinner-32 CommonAssemblyInfo.cs NuGet 0.18.3.1 December 03, 2012
Octocat-spinner-32 LICENSE.txt Added MIT License text October 19, 2010
Octocat-spinner-32 NugetPackAll.cmd Fix bugs with odd types and ToScalarOrDefault June 10, 2011
Octocat-spinner-32 NugetPushAll.cmd Merging June 19, 2011
Octocat-spinner-32 PerformanceTestConsole.psess Added UseSharedConnection to AdoAdapter November 23, 2011
Octocat-spinner-32 PerformanceTestConsole111123.vsp Added UseSharedConnection to AdoAdapter November 23, 2011
Octocat-spinner-32 README.md Added a link to the SimpleFx (documentation) Github project June 12, 2013
Octocat-spinner-32 Simple.Data-Mono.sln Added Release-Mono configuration November 27, 2011
Octocat-spinner-32 Simple.Data-Mono.userprefs Added Release-Mono configuration November 27, 2011
Octocat-spinner-32 Simple.Data.sln Removed MediumTrust app October 08, 2012
Octocat-spinner-32 Simple.Data.sln.DotSettings Added ReSharper overrides, ignored ReSharper settings April 07, 2013
Octocat-spinner-32 Simple.Data.userprefs Basic CRUD operations working October 03, 2011
Octocat-spinner-32 Simple.Data.vsmdi Added UpdateBy dynamic method. August 06, 2010
Octocat-spinner-32 Simple_Data.ndproj Just doing some cleaning up March 16, 2012
Octocat-spinner-32 cleanup.sh Release 0.18.2.1 October 12, 2012
Octocat-spinner-32 replacenugetversion.sh Release 0.18 August 30, 2012
README.md

Simple.Data

A lightweight, dynamic data access component for .NET, written in C#.

What is it?

Prompted by the need for an easy-to-use database access component which prevents SQL injection attacks while not requiring lots of boilerplate ADO.NET code or a pre-generated ORM model. Inspired by Ruby's ActiveRecord and DataMapper gems.

Instead of

public User FindUserByEmail(string email)
{
    User user = null;
    using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Default"].ConnectionString))
    using (var command = new SqlCommand("select id, email, hashed_password, salt from users where email = @email", connection))
    {
        command.Parameters.Add("@email", SqlDbType.NVarChar, 50).Value = form.Email);
        connection.Open();
        using (var reader = command.ExecuteReader())
        {
            if (reader.Read())
            {
                user = new User {Id = reader.GetInt32(0), Email = reader.GetString(1), Password = reader.GetString(2), salt = reader.GetString(3)};
            }
        }
    }
    return user;
}

why not just write

public User FindUserByEmail(string email)
{
    return Database.Open().Users.FindAllByEmail(email).FirstOrDefault();
}

and take the rest of the morning off?

Simple.Data does this by using the dynamic features of .NET 4 to interpret method and property names at runtime and map them to your underlying data-store with a convention-based approach. For the code above, there is no pre-defined type with a Users property, and no FindByEmail method. Within Simple.Data, that single line of code is converted into all the ADO.NET boilerplate for you.

Multiple database and NoSQL store support

Because Simple.Data provides a sort of dynamic Domain Specific Language to represent queries, inserts, updates and deletes, it is able to support not only a wide range of RDBMS engines, but also non-SQL-based data stores such as MongoDB. It has an open and flexible model of Adapters and Providers which make it simple to write plug-ins to map to almost any back-end.

Currently, Simple.Data has adapters for:

  • ADO-based access to relational databases, with providers for:
    • SQL Server 2005 and later (including SQL Azure)
    • SQL Server Compact Edition 4.0
    • Oracle
    • MySQL 4.0 and later
    • SQLite
    • PostgreSQL
    • SQLAnywhere
    • Informix
  • MongoDB
  • OData

Work is in progress to support Azure Table Storage. I'm also ensuring that Simple.Data works on Mono by the 1.0 release.

If you'd like to create an adapter or provider and need some help to get started, drop in on the mailing list (see below).

Resources

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

Something went wrong with that request. Please try again.