Simple.Data
.NET database access made easier
ADO.NET
using (var connection = new SqlConnection(connectionString)) {
using (var command = connection.CreateCommand()) {
...
Microsoft.Data
// What you should do...
using (var database = Database.Open())
{
var sql = "select Id, FirstName, LastName...
Microsoft.Data
// What PHP refugees will actually do...
using (var database = Database.Open())
{
var sql = "select Id, Fir...
Simple.Data
var database = Database.Open();
return database.People.FindById(id);
// Easier to do it right
Simple.Data…
…is Database agnostic
…is naming-style tolerant
PascalCase, SHOUTY_CASE, snake_case
…favours Convention o...
Simple CRUD
db.People.Insert(Id: 1, FirstName: “Bob”, …);
db.People.FindAllByName(“Bob”);
db.People.FindByFirstNameAndLast...
Complex queries
 db.Find(db.Users.JoinDate >= new DateTime(2010,11,13);
 db.Find(db.Posts.Comments.Approved != "Y")
 db...
Simple O/RM
var person = db.People.FindById(1);
foreach (var telNo in person.PhoneNumbers)
{
if (telNo.DiallingCode.Starts...
Simple.Data…
…is Open Source (MIT license)
…can be downloaded from:
http://github.com/markrendle/Simple.Data/
…wants to...
Upcoming SlideShare
Loading in …5
×

Simple.Data intro slides

920
-1

Published on

Slides from the Simple.Data intro talk

Published in: Technology
1 Comment
1 Like
Statistics
Notes
  • ritakoneh@hotmail.co.uk
    Hello My New friend
    My name is rita i saw your profile at(www.slideshare.net) and i love it i think we can click so please i will like you to email me back through my email address thus: so that i can told you more about me and give you my sweet picture so that you can know me will ok.
    Awaiting to see your lovely reply soonest.
    Miss rita ritakoneh@hotmail.co.uk
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
920
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
12
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide

Simple.Data intro slides

  1. 1. Simple.Data .NET database access made easier
  2. 2. ADO.NET using (var connection = new SqlConnection(connectionString)) { using (var command = connection.CreateCommand()) { command.CommandText = "select Id, FirstName, LastName“ + " from people where Id = @id"; command.Parameters.Add("@id", SqlDbType.Int).Value = id; connection.Open(); using (var reader = command.ExecuteReader()) { if (reader.Read()) { return new Person { Id = reader.GetInt32(0), FirstName = reader.IsDBNull(1) ? “” : reader.GetString(1), LastName = reader.IsDBNull(2) ? “” : reader.GetString(2), }; } } } }
  3. 3. Microsoft.Data // What you should do... using (var database = Database.Open()) { var sql = "select Id, FirstName, LastName" + " from people where Id = @0"; return database.Query(sql, id); }
  4. 4. Microsoft.Data // What PHP refugees will actually do... using (var database = Database.Open()) { var sql = "select Id, FirstName, LastName" + " from people where Id = “ + id; return database.Query(sql); }
  5. 5. Simple.Data var database = Database.Open(); return database.People.FindById(id); // Easier to do it right
  6. 6. Simple.Data… …is Database agnostic …is naming-style tolerant PascalCase, SHOUTY_CASE, snake_case …favours Convention over Configuration …is not an O/RM
  7. 7. Simple CRUD db.People.Insert(Id: 1, FirstName: “Bob”, …); db.People.FindAllByName(“Bob”); db.People.FindByFirstNameAndLastName(“Bob”, “X”); db.People.UpdateById(Id: 1, FirstName: “Robert”); db.People.DeleteById(1);
  8. 8. Complex queries  db.Find(db.Users.JoinDate >= new DateTime(2010,11,13);  db.Find(db.Posts.Comments.Approved != "Y")  db.Find(db.Users.Age >= 18 && db.Users.Age <= 35)  (Simple.Data uses operator overloading to turn these expressions into its own SimpleExpression objects)
  9. 9. Simple O/RM var person = db.People.FindById(1); foreach (var telNo in person.PhoneNumbers) { if (telNo.DiallingCode.StartsWith(“07”)) { SendSpamText(telNo); } }
  10. 10. Simple.Data… …is Open Source (MIT license) …can be downloaded from: http://github.com/markrendle/Simple.Data/ …wants to be forked, patched and loved Mark Rendle ~ twitter.com/markrendle ~ blog.markrendle.net
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×