标签:span pre initial alt 功能 官方 partial color mod
近端时间从推酷app上了解到C#轻微型的ORM框架--PetaPoco。从github Dapper 开源项目可以看到PetaPoco排第四
以下是网友根据官方介绍翻译,这里贴出来。
PetaPoco是一款适用于.Net 和Mono的微小、快速、单文件的微型ORM。
PetaPoco有以下特色:
如何获取PetaPoco?
因为中国使用win7系统的比较多,然后win7自带.net3.5框架,所以笔者从nuget下载了4.0.3版本的PetaPoco
获取地址:
可以和笔者一样安装4.0.3版本
如下图,回车即可
下面贴出一部分测试代码
using PetaPocoDemo.Models; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace PetaPocoDemo { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { //创建一个petapoco对象 var db = new PetaPoco.Database("connectionString"); //遍历查询文章表 foreach (var a in db.Query<article>("select * from article")) { MessageBox.Show(a.article_id + "-------" + a.title); } //返回一个scalar数量 var count = db.ExecuteScalar<int>("select count(*) from article"); MessageBox.Show("count:" + count.ToString()); //返回一行记录 var row = db.SingleOrDefault<article>("select * from article where article_id=‘1‘"); MessageBox.Show(row.content); //插入记录 var newArticle = new article(); newArticle.article_id = 2; newArticle.title = "绿书"; newArticle.content = "可持续发展绿色内容"; newArticle.date_created = DateTime.UtcNow; if (Convert.ToInt32(db.Insert("article", "article_id",false, newArticle)) > 0) { MessageBox.Show("sucess"); } else { MessageBox.Show("fail"); } } } }
未完待续
标签:span pre initial alt 功能 官方 partial color mod
原文地址:http://www.cnblogs.com/xiefengdaxia123/p/6017958.html