• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

Simple.Data intro slides

on

  • 932 views

Slides from the Simple.Data intro talk

Slides from the Simple.Data intro talk

Statistics

Views

Total Views
932
Views on SlideShare
925
Embed Views
7

Actions

Likes
1
Downloads
7
Comments
1

1 Embed 7

http://lanyrd.com 7

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • 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
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Simple.Data intro slides Simple.Data intro slides Presentation Transcript

    • Simple.Data
      .NET database access made easier
    • 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),
      };
      } } } }
    • Microsoft.Data
      // What you should do...
      using (vardatabase = Database.Open())
      {
      varsql = "select Id, FirstName, LastName"
      + " from people where Id = @0";
      return database.Query(sql, id);
      }
    • Microsoft.Data
      // What PHP refugees will actually do...
      using (vardatabase = Database.Open())
      {
      varsql = "select Id, FirstName, LastName"
      + " from people where Id = “ + id;
      return database.Query(sql);
      }
    • 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 over Configuration
      …is not an O/RM
    • 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);
    • 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)
    • Simple O/RM
      var person = db.People.FindById(1);foreach (vartelNo in person.PhoneNumbers){ if (telNo.DiallingCode.StartsWith(“07”)) {SendSpamText(telNo); }}
    • 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