代码拉取完成,页面将自动刷新
开发环境:vs2013、asp.net mvc 4
前端: BootStrap 3 Layer Jquery 后端: 三层+MVC4
传送门: Core:https://gitee.com/hao-zhi-ying/HzyAdmin
H+:https://github.com/HaoZhiYing/HPlus
--集成通配权限管理
--ORM 大部分使用 拉姆达 表达式 操作
--ORM 举例:
DBContext db=new DBContext();//默认sqlserver 数据库 默认链接字符串 ConnectionString 自动会去 app.config 查找
DBContext db=new DBContext(DataBaseType.MySql);///Mysql 数据库 默认链接字符串 ConnectionString 自动会去 app.config 查找
DBContext db=new DBContext(DataBaseType.MySql,"链接字符串");
//新增
//新增
var user = new TestT_Users();
user.cUsers_Name = "123";
user.cUsers_LoginPwd = "123";
user.cUsers_LoginName = "123";
user.cUsers_Email = "123";
db.Add(user);
user.uUsers_ID = db.Add(user, true).To_Guid();//第二个参数表示验证字段信息
if (user.uUsers_ID == Guid.Empty) throw new Exception(db.ErrorMessge);
db.Add(user, li);//获取 sql 默认存入 li 中
db.Commit(li);//提交事务
//插入单个字段
db.Add(() => new TestT_Users()
{
cUsers_Name = "haha"
});
//修改
user = new TestT_Users();
user.cUsers_Name = "123";
user.cUsers_LoginPwd = "123";
user.cUsers_LoginName = "123";
user.cUsers_Email = "123";
db.Edit(user, w => w.uUsers_ID == Guid.Empty);//修改所有的字段
db.Edit(() => new TestT_Users()
{
cUsers_Name = "哈哈"
}, w => w.uUsers_ID == Guid.Empty);
//删除
db.Delete<TestT_Users>(w => w.uUsers_ID == Guid.Empty && w.cUsers_Name == null);
db.Delete<TestT_Users>(w => w.uUsers_ID == Guid.Empty, li);
db.Commit(li);
//查询
var dt = db.Find("select * from " + user.GetTabelName() + " where 1=1");//原始 sql 得到 DataTable
var model = db.Find<TestT_Users>(w => w.uUsers_ID == Guid.Empty);//单表
var name = "admin";
var list = db.FindList<TestT_Users>(w => w.cUsers_LoginName.Like("%" + name + "%"), " dUsers_CreateTime desc ");//单表集合
//多表查询
var iquery =db.Find<TestT_Users, TestMember>()
.Query((a, b) => new { a.uUsers_ID, a.cUsers_Email, a.cUsers_LoginName, a.cUsers_Name, b.Member_Name, b.Member_Sex, b.Member_CreateTime, _ukid = a.uUsers_ID })
.LeftJoin((a, b) => a.uUsers_ID == b.Member_ID && a.cUsers_Email == "1231231", "b")
.Where((a, b) => a.uUsers_ID == Guid.Empty);
var sql = iquery.ToSQL();//获取sql
var list_db = iquery.ToList();//获取 字典集合 List<Dictionary<string, object>>
var dt1 = iquery.ToDataTable();//获取 DataTable
//其他
db.FindObject("select count(1) from " + user.GetTabelName() + " where 1=1 and a=b").To_Int();
DataRow dr = null;//这里只是举例
db.DataRowToModel<TestT_Users>(dr);//将 DataRow 转换为 实体 TestT_Users
List<Dictionary<string, object>> newLi = db.FindList("这里 是 sql");
bool isok = db.CheckModel<TestT_Users>(user);//验证实体 的字段 是否 为空 等等。。。。
if (!isok) throw new Exception(db.ErrorMessge);//db.ErrorMessge 可能存放 用户名不能为空.....
var json = db.jss.Serialize(user);//序列化 为 json 串
//db.dbhelper 原始 数据库访问
/// <summary>
/// 查询
/// </summary>
/// <param name="QuickConditions"></param>
/// <param name="pageindex"></param>
/// <param name="pagesize"></param>
/// <returns></returns>
public PagingEntity GetDataSource(Hashtable query, int pageindex, int pagesize)
{
string where = "";
where += string.IsNullOrEmpty(query["cUsers_Name"].To_String()) ? "" : " and cUsers_Name like '%" + query["cUsers_Name"].To_String() + "%' ";
where += string.IsNullOrEmpty(query["cUsers_LoginName"].To_String()) ? "" : " and cUsers_LoginName like '%" + query["cUsers_LoginName"].To_String() + "%' ";
var sql = db.Find<TestT_Users, TestMember>()
.Query((a, b) => new { a.uUsers_ID, a.cUsers_Email, a.cUsers_LoginName, a.cUsers_Name, b.Member_Name, b.Member_Sex, b.Member_CreateTime, _ukid = a.uUsers_ID })
.LeftJoin((a, b) => a.uUsers_ID == b.Member_ID && a.cUsers_Email == "1231231", "b")
.Where((a, b) => a.uUsers_ID == Guid.Empty)
.ToSQL();
var pe = db.Find(sql, " dUsers_CreateTime ", false, pageindex, pagesize);
return new ToJson().GetPagingEntity(pe, new List<BaseEntity>()
{
new T_Users(),
new T_Roles()
});
}
登录: 首页: 皮肤: 列表: 添加/修改: =============手机版本============== 列表: 添加/修改:
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。