轻量级.Net ORM SqlSuger项目实战
SqlSuger,清垃圾ORM实战例子。
//添加引用 using SqlSugar; //在构造函数中实例化SqlSuger clinet = new SqlSugarClient(new ConnectionConfig() { InitKeyType = InitKeyType.Attribute, ConnectionString = "......",//这里是数据库连接字符串 DbType = SqlSugar.DbType.SqlServer, IsAutoCloseConnection = true }); //连表查询 BaseUserCollection con = new BaseUserCollection(); var query = clinet.Queryable<Base_Users, Base_Roles>((t1, t2) => t1.RoleID == t2.RoleID).Select<Base_Role_User>(); if(query != null) { con.List = await query.ToPageListAsync(pageIndex, pageSize); con.Count = await query.CountAsync(); } return con; //插入数据 return await clinet.Insertable(security).ExecuteReturnIdentityAsync();