GithubHelp home page GithubHelp logo

darrencauthon / simple.data Goto Github PK

View Code? Open in Web Editor NEW

This project forked from markrendle/simple.data

0.0 2.0 0.0 18.79 MB

A light-weight, dynamic data access component for .NET 4.0

License: MIT License

simple.data's Introduction

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.FindByEmail(email);
}

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
    • SQL Server Compact Edition 4.0
    • MySQL 4.0 and later
    • SQLite
  • MongoDB

We are expecting more ADO Providers to support Oracle, PostgreSQL and more, and Adapters for CouchDB, Redis, Azure Table Storage, Amazon SimpleDB...

Resources

simple.data's People

Contributors

markrendle avatar flq avatar darrencauthon avatar vansha avatar okify avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.