数据库基本操作

  • 查询姓名中包含"张三"的记录
new PojoEntity { UserName = "张三" }.Mapper;
  • 插入一条新记录,如果主键是自增长,则返回刚刚插入的ID
var result = new PojoEntity { UserName = "李四" }.Mapper.Create();
  • 使用主键ID值更新记录,设置UserName为“王五”
new PojoEntity { ID = result, UserName = "王五" }.Mapper.Update();
  • 将所有UserName为“王五”的记录删除
new PojoEntity { UserName = "王五" }.Mapper.Detete();
  • 分页查询
new PojoEntity { UserName = "张三" }.Mapper.SelectPage(1, 20);
  • 管理数据库事务
PojoRepository pojoRP = new PojoRepository();
TransactionManager.Define()
    .AddMethod(cmd =>
    {
        pojoRP.Use(cmd).Create(new PojoEntity { UserName = "张三" });
        pojoRP.Use(cmd).Create(new PojoEntity { UserName = "李四" });
    })
    .Commit();

下一页:逻辑层框架:IOC/AOP/Message Bus/CQRS

Last edited Feb 25, 2013 at 9:57 AM by gameboyLV, version 6

Comments

No comments yet.