当前位置: 首页>>代码示例>>C#>>正文


C# DbHelper.ExecuteReaderExt方法代码示例

本文整理汇总了C#中DbHelper.ExecuteReaderExt方法的典型用法代码示例。如果您正苦于以下问题:C# DbHelper.ExecuteReaderExt方法的具体用法?C# DbHelper.ExecuteReaderExt怎么用?C# DbHelper.ExecuteReaderExt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DbHelper的用法示例。


在下文中一共展示了DbHelper.ExecuteReaderExt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetOne

        public User GetOne(Where @where, string fields) {
            using (SqlCommand command = new DbHelper().Command) {
                User user = new User();
                string sql = $"select top 1 {fields} from {Table} where {where.Result};";
                IDataReader reader = command.ExecuteReaderExt(sql, where);

                if (reader.Read()) {
                    user = ReaderModel(reader, fields);
                }
                return user;
            }
        }
开发者ID:kangwl,项目名称:DotNet.Mix,代码行数:12,代码来源:UserDal.cs

示例2: GetList

        public List<User> GetList(Where where, string fields, string orderby, int pageIndex, int pageSize) {

            string sqlBase = $"select {fields} from {Table} where {@where.Result} ";
            const string sqlPageBase = @"select * from( 
                            select *,ROW_NUMBER() OVER (ORDER BY {1}) as rank from ({0})a 
                          )as t where t.rank between {2} and {3}";

            int startPageIndex = (pageIndex - 1)*pageSize + 1;
            int endPageIndex = pageIndex*pageSize;

            string sqlPage = string.Format(sqlPageBase, sqlBase, orderby, startPageIndex, endPageIndex);
            using (SqlCommand command = new DbHelper().Command) {
                List<User> users = new List<User>();
                IDataReader reader = command.ExecuteReaderExt(sqlPage, where);
                while (reader.Read()) {

                    User user = ReaderModel(reader, fields);
                    users.Add(user);
                }
                return users;
            }
        }
开发者ID:kangwl,项目名称:DotNet.Mix,代码行数:22,代码来源:UserDal.cs

示例3: GetRecordCount

 public int GetRecordCount(Where @where) {
     string sql = $"select count(1) total from {Table} where {where.Result};";
     using (SqlCommand command = new DbHelper().Command) {
         command.CommandText = sql;
         command.CommandType = CommandType.Text;
         IDataReader reader = command.ExecuteReaderExt(sql, where);
         if (reader.Read()) {
             object countObj = reader["total"];
             return countObj.ToInt();
         }
         return 0;
     }
 }
开发者ID:kangwl,项目名称:DotNet.Mix,代码行数:13,代码来源:User_Dal.cs


注:本文中的DbHelper.ExecuteReaderExt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。