/// <summary> /// 查询 /// </summary> /// <typeparam name="T">类型</typeparam> /// <param name="query"></param> /// <returns></returns> public static List <T> BaseGetListByParam <T>(BaseQuery query) { using (IDbConnection conn = new SqlConnection(ConnString)) { conn.Open(); List <T> item = conn.Query <T>(query.Sql, query.Obj).ToList(); conn.Close(); return(item); } }
public static int BaseGetCountByParam(BaseQuery query) { using (IDbConnection conn = new SqlConnection(ConnString)) { conn.Open(); int count = conn.QueryFirst(query.Sql, query.Obj); conn.Close(); return(count); } }
/// <summary> /// 查询 /// </summary> /// <typeparam name="T">类型</typeparam> /// <param name="query"></param> /// <returns></returns> public static T BaseGetByParam <T>(BaseQuery query) { using (IDbConnection conn = new SqlConnection(ConnString)) { conn.Open(); T item = conn.Query <T>(query.Sql, query.Obj).FirstOrDefault(); conn.Close(); return(item); } }