Simple.Data – introduction

I want to show you simple library to accessing and modyfing database. Simple.Data is some kind of ORM but very lightweight ORM. In my opinion it could be use in simple projects.

I’ll create vary simple application (I’ll use SqlCompact) and if you want to know more you could get more information here. Let’s start 🙂
So, I’m creating Console Application and installing all necessary libraries by NuGet:

After that, I’m creating database:

After that, I’m adding connection string to App.config:

After that, I’m adding stars to database and next I’ll get them from database:
using Simple.Data;
using System;

namespace Letys.SimpleDataExample
class Program
static void Main(string[] args)
var db = Database.OpenNamedConnection(“MyConnectionSring”);

db.Stars.Insert(Name: “Sun”, Hydrogen: 73.46);
db.Stars.Insert(Name: “Alpha Centauri”, Hydrogen: 79.68);

var insertedStars = db.Stars.All();

foreach (var item in insertedStars)
Console.WriteLine(string.Format(“{0}: {1}%”, item.Name, item.Hydrogen));

And the result:

I hope that you’ll read more here