-
Notifications
You must be signed in to change notification settings - Fork 600
Quick start
Wade Baglin edited this page Dec 15, 2015
·
9 revisions
public class Article
{
public long Id { get; set; }
public string Title { get; set; }
public DateTime DateCreated { get; set; }
public bool Draft { get; set; }
public string Content { get; set; }
}
For more information about mapping entities, see mapping
var db = new PetaPoco.Database("connectionStringName");
For more information about instantiating PetaPoco, see ways to instantiate PetaPoco
var article = new Article { Title = "Our first entry", DateCreated = DateTime.UtcNow(), Content = "Some content..." };
db.Save("Articles", "Id", article);
// With more advanced mapping, you could have called db.Save(article);
For more information about inserting, updating or saving entities, see inserting, updating and saving
foreach (var a in db.Query<article>("SELECT * FROM Articles"))
{
Console.WriteLine($"{a.Id} - {a.Title}");
}
For more information about querying, see querying
db.Delete("Articles", "Id", article.Id);
// Or db.Delete("Articles", "Id", article);
// With more advanced mapping, you could have called db.Delete(article);
PetaPoco is proudly maintained by the Collaborating Platypus group and originally the brainchild of Brad Robinson