PetaPoco:适用于.NET的微型ORM

时间:2016-10-12 04:10:15
【文件属性】:
文件名称:PetaPoco:适用于.NET的微型ORM
文件大小:17KB
文件格式:RAR
更新时间:2016-10-12 04:10:15
PetaPoco ORM PetaPoco不需要引用dll,只需要添加一个cs文件到项目。运行效率据称也较高,比较接近原生SQL操作。 db.Query
("SELECT * FROM articles"); //直接SQL语句 db.Page
(1, 20, "SELECT * FROM articles WHERE category=@0 ORDER BY date_posted DESC", "coolstuff"); //分页 // Insert a record var a=new article(); a.title="My new article"; a.content="PetaPoco was here"; a.date_created=DateTime.UtcNow; db.Insert(a); // Update it a.content="Blah blah"; db.Update(a); // Delete it db.Delete(a); using (var scope=db.Transaction) { //事务代码 scope.Complete(); } //条件检索画面: var id=123; var sql=PetaPoco.Sql.Builder .Append("SELECT * FROM articles") .Append("WHERE article_id=@0", id); if (start_date.HasValue) sql.Append("AND date_created>=@0", start_date.Value); if (end_date.HasValue) sql.Append("AND date_created<=@0", end_date.Value); var a=db.Query
(sql)
【文件预览】:
PetaPocoMapper.cs
Attribute.cs
PetaPoco.cs

网友评论

  • 很强大,很好用,快速上手
  • 很强大,很好用,快速上手