• Stars
    star
    1,329
  • Rank 35,356 (Top 0.7 %)
  • Language
    C#
  • License
    MIT License
  • Created over 14 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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 !

More Repositories

1

Simple.Web

A lightweight, object-oriented (Model-View-Handler) framework for modern web development in .NET.
C#
231
star
2

Flux

Lightweight web server for .NET and Mono
C#
70
star
3

Simple.Data.Pad

A GUI tool for writing Simple.Data queries, with database-driven auto-completion.
C#
24
star
4

brackets-grunt

A Brackets extension to run Grunt tasks
JavaScript
21
star
5

AngularTS

A TypeScript Declaration Source File for AngularJS
JavaScript
16
star
6

Simple.Data.Sample

Sample project demonstrating features of Simple.Data
C#
15
star
7

nogit

Disable Git SCC plug-in in Visual Studio 2013 to 2017
C#
15
star
8

moist.js

Write HTML as JavaScript
14
star
9

grunt-typescript

TypeScript compilation task for Grunt
JavaScript
12
star
10

CodeProjector

A VS2010 plug-in to reflect code window to a separate window, for projecting in presentations
C#
11
star
11

Myxo

Jasmine in C#
C#
9
star
12

Simple.Data.Azure

Azure Table Service adapter for Simple.Data
C#
9
star
13

mofo

Everybody seems to be creating serialization formats, so here's mine: Mark's Object FOrmat
8
star
14

AzureStorageToolList

Single-page site providing a list of tools for working with Windows Azure Storage
JavaScript
7
star
15

NancyTwitter

Authenticating a Nancy application using Twitter OAuth
C#
7
star
16

FuncLinq

An even more functional version of Bart de Smet's MinLinq
C#
7
star
17

ripgac

A site about ASP.NET vNext
C#
7
star
18

Trespasser

Dynamic proxy for accessing non-public members in .NET tests.
C#
6
star
19

FunctionalAlchemy

Code from the Functional Alchemy talk
C#
6
star
20

AngularTS-Minify-Demo

DI-compatible Minification with AngularJS and TypeScript
JavaScript
5
star
21

todo-sample

Reference implementation of Nancy/SimpleData ToDo list app
C#
5
star
22

SimpleWebSignupDemo

A demo signup application for Simple.Web
C#
5
star
23

FluxUv

Flux on libuv
C#
5
star
24

Heckle

Live feedback for presenters and audience
C#
4
star
25

InterfaceTests.Net

A repository of copyable tests for implementations of .NET BCL interfaces
C#
4
star
26

NExtLib

General purpose extension library for Microsoft .NET and Mono
C#
4
star
27

MvvmRx

A Model-View-ViewModel implementation using the Reactive Framework from Microsoft DevLabs
C#
4
star
28

Simple

Extracts from Simple projects into a useful library
C#
3
star
29

StreamIntro

Console application that I use for my Twitch stream intro
C#
3
star
30

BedAndBroadband

Simple.Web Demo code from MonkeySpace 2013
JavaScript
3
star
31

WpfPrimitives

Some basic stuff that should be in WPF but isn't.
C#
3
star
32

Simple.WebServer

This is not a real thing. It's just an OWIN spike.
C#
3
star
33

AsyncWrapperGenerator

Generates TAP Async extension methods from Begin/End methods
C#
3
star
34

Simple.Data.VistaDB

Simple.Data ADO Provider for VistaDB
C#
3
star
35

ConcurrentSet

A thread-safe Set with no locks. I think.
C#
2
star
36

bamlats

TypeScript
2
star
37

Extensions

Extensions for .NET
C#
2
star
38

MEFF

MEF Function Export Provider
C#
2
star
39

Aggro

A game created using Silverlight.
C#
2
star
40

ProgNet13

Code for ProgNet13
JavaScript
2
star
41

PocketIDE

JavaScript
2
star
42

tweaker

An ASP.NET module to fix the horrible HTML that some things generate
JavaScript
2
star
43

Simple.Migrations

Class-based migrations for .NET
C#
2
star
44

Confabulum

Duplex presentations
C#
2
star
45

CoffeeScriptVS

C#
2
star
46

AzureDocumentStore

Indexed JSON document storage R&D
JavaScript
2
star
47

GrpcWindowsService

C#
1
star
48

XMap

XML-POCO mapper
C#
1
star
49

SemanticConventionLibraryGenerator

Generate .NET types representing OpenTelemetry Semantic Conventions
C#
1
star
50

markrendle.github.com

Github page
1
star
51

blazor-desktop-select-issue

Repro solution for bug with `select` controls in Blazor Desktop
CSS
1
star
52

gotocms

Demo of Node.js CMS for GOTO Amsterdam 2012
JavaScript
1
star
53

Simple.Data.Docs

Documentation for Simple.Data
1
star
54

TaskBoard

Silverlight TaskBoard
JavaScript
1
star
55

essentialdotnet

Source for essentialdotnet.com
1
star
56

fretweb

C#
1
star
57

OneBRC

C#
1
star
58

IronMock

Proof-of-concept .NET mocking library using DLR and embedded IronRuby
C#
1
star
59

blog

My blog
HTML
1
star