好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

基于.NET C#的 sqlite 数据库 ORM 【Easyliter】

void Main( string [] args) { var connstr = " DataSource= " + System.AppDomain.CurrentDomain.BaseDirectory + " mapping.sqllite " ; // 依赖于 System.Data.SQLite Easyliter e = new Easyliter(connstr); // 从数据库创建类 var createCalss1 = e.CreateCalss( " Sqlite.Model " /* 命名空间 */ , @" D:\工作\Sqlite\Sqlite\model " /* 路径 */ ); // 根据SQL语句创建类,多表查询会用到 var createCalss2 = e.CreateCalssBySql( " Sqlite.Model " , @" D:\工作\Sqlite\Sqlite\model " , " viewproduct " , " select id,sku from product " ); // 删除 // e.Delete<Product>(100); // e.Delete<Product>(new int [] {1,2,3}); // 更新 // e.Update<Product>(new { sku = "x2",category_id=1 }, new { id=434 }); /// /添加 // Product p = new Product() // { // category_id = 2, // sku = "sku", // title = "title" // }; // e.Insert<Product>(p); /// /根据sql查询 List<Product> list = e.Select<Product>( " select * from product where id>@num " , new { num= 100 }); // 无条件 List<Category> list2 = e.Select<Category> (); // 单条件 List<Product> list3 = e.Select<Product>(x=>x.id> 200 ); // 多条件 List<Product> list4 = e.Select<Product>(x => x.id > 200 , x => x.sku== " skx " ||x.sku== null ); // 多条件分页 int count = 0 ; List <Product> list5 = e.SelectPage<Product>( 1 , 10 , ref count, " id desc " , x =>x.id > 10 , // 条件1 x=> true ); // 条件2 ...条件N // var dt = e.GetDataTable("select * from product order by id desc"); }

 

 

 

源码地址: http://git.oschina.net/sunkaixuan/Easyliter

 

基于.NET C#的 sqlite 数据库 ORM 【Easyliter】

标签:

查看更多关于基于.NET C#的 sqlite 数据库 ORM 【Easyliter】的详细内容...

  阅读:38次