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


C# SqlQuery.ExecuteReader方法代码示例

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


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

示例1: GetLastChatMessages

        public override ChatMessageCollection GetLastChatMessages(int userID, int targetUserID, int lastMessageID, int MessageCount)
        {
            ChatMessageCollection result;
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_Chat_GetLastMessages";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter<int>("@UserID", userID, SqlDbType.Int);
                query.CreateParameter<int>("@TargetUserID", targetUserID, SqlDbType.Int);
                query.CreateParameter<int>("@LastMessageID", lastMessageID, SqlDbType.Int);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    result = new ChatMessageCollection();

                    while (reader.Read())
                    {
                        result.Insert(0, new ChatMessage(reader));
                    }
                }

                return result;
            }
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:25,代码来源:ChatDao.cs

示例2: GetCommentsBySearch

        public override CommentCollection GetCommentsBySearch(int operatorID, Guid[] excludeRoleIDs, AdminCommentFilter filter, int pageNumber)
        {
            using (SqlQuery query = new SqlQuery())
            {
                string conditions = BuildConditionsByFilter(query, filter, false, operatorID, excludeRoleIDs);

                query.Pager.TableName = "[bx_Comments]";
                query.Pager.SortField = filter.Order.ToString();
                query.Pager.IsDesc = filter.IsDesc;
                query.Pager.PageNumber = pageNumber;
                query.Pager.PageSize = filter.PageSize;
                query.Pager.SelectCount = true;

                query.Pager.Condition = conditions.ToString();

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    CommentCollection comments = new CommentCollection(reader);

                    if (reader.NextResult())
                    {
                        if (reader.Read())
                        {
                            comments.TotalRecords = reader.Get<int>(0);
                        }
                    }

                    return comments;
                }
            }
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:31,代码来源:CommentDao.cs

示例3: LoadClientInstruct

        public override List<Instruct> LoadClientInstruct(int clientID, int loadCount, out int laveCount)
        {
            List<Instruct> results = new List<Instruct>();
            laveCount = 0;
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = @"SELECT TOP (@LoadCount) * FROM bx_Instructs WHERE ClientID = @ClientID;
                SELECT Count(*)  FROM bx_Instructs WHERE ClientID = @ClientID;";
                query.CreateParameter<int>("@ClientID", clientID, SqlDbType.Int);
                query.CreateTopParameter("@LoadCount", loadCount);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    while (reader.Next)
                    {
                        results.Add(new Instruct(reader));
                    }

                    reader.NextResult();
                    if (reader.Next)
                        laveCount = reader.Get<int>(0);

                    laveCount-=loadCount;

                    if(laveCount<=0)
                        laveCount=0;
                }

                return results;
            }
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:31,代码来源:PassportDao.cs

示例4: GetDataBaseInfo

        public override DataBaseInfo GetDataBaseInfo()
        {
            string version = "";

            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "SELECT size*8,(status & 0x40) as type FROM sysfiles;SELECT @@VERSION";
                DataBaseInfo dataBaseInfo = new DataBaseInfo();
                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    int dataSize = 0;
                    int logoSize = 0;
                    while (reader.Read())
                    {
                        if (reader.GetInt32(1) == 0)
                            dataSize += reader.GetInt32(0);
                        else
                            logoSize += reader.GetInt32(0);
                    }
                    if (reader.NextResult())
                    {
                        while (reader.Read())
                            version += "(" + reader.GetString(0) + ")";
                    }
                    dataBaseInfo.DataSize = dataSize * 1024;
                    dataBaseInfo.LogSize = logoSize * 1024;
                    dataBaseInfo.Version = version;
                }
                return dataBaseInfo;
            }
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:31,代码来源:DatabaseInfoDao.cs

示例5: CreateSerial

        public override MaxSerial CreateSerial(int ownerUserId, DateTime expriseDate, SerialType type, string data,out bool success)
        {
            using (SqlQuery query = new SqlQuery())
            {
                Guid serial = Guid.NewGuid();

                DateTime createDate = DateTimeUtil.Now;

                query.CommandText = "bx_CreateSerial";
                query.CommandType = System.Data.CommandType.StoredProcedure;
                query.CreateParameter<int>("@UserID", ownerUserId, SqlDbType.Int);
                query.CreateParameter<DateTime>("@ExpiresDate", expriseDate, SqlDbType.DateTime);
                query.CreateParameter<byte>("@Type", (byte)type, SqlDbType.TinyInt);
                query.CreateParameter<string>("@Data", data, SqlDbType.NVarChar, 1000);

                SqlParameter outputParam = query.CreateParameter<bool>("@Success", SqlDbType.Bit, ParameterDirection.Output);

                MaxSerial newSerial = null;
                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    while (reader.Next)
                    {
                        newSerial = new MaxSerial(reader);
                    }
                }

                success = (bool)outputParam.Value;
                return newSerial;
            }
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:30,代码来源:SerialDao.cs

示例6: GetLastestCommentsForSomeone

        public override CommentCollection GetLastestCommentsForSomeone(int targetUserID, CommentType type, int top)
        {
            using (SqlQuery query = new SqlQuery())
            {
                string getTargetNameSql = null;

                switch (type)
                {
                    case CommentType.Blog:
                        getTargetNameSql = "(SELECT [Subject] FROM [bx_BlogArticles] WHERE [ArticleID]=TargetID) AS [TargetName] ";
                        break;

                    case CommentType.Photo:
                        getTargetNameSql = "(SELECT [Name] FROM [bx_Photos] WHERE [PhotoID]=TargetID) AS [TargetName] ";
                        break;

                    default:
                        getTargetNameSql = string.Empty;
                        break;
                }

                query.CommandText = "SELECT TOP (@TopCount) *, " + getTargetNameSql + " FROM bx_Comments WHERE [TargetUserID][email protected] AND [Type][email protected] ORDER BY [CommentID] DESC";
                query.CommandType = CommandType.Text;

                query.CreateParameter<int>("@TargetUserID", targetUserID, SqlDbType.Int);
                query.CreateParameter<CommentType>("@Type", type, SqlDbType.TinyInt);

                query.CreateTopParameter("@TopCount", top);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    return new CommentCollection(reader);
                }
            }
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:35,代码来源:CommentDao.cs

示例7: GetPointStatInfo

        public override void GetPointStatInfo(PointLogFilter filter, int pointIndex, out int count, out int produceCount, out int consumeCount)
        {
            using (SqlQuery query = new SqlQuery())
            {
                StringBuilder sb = new StringBuilder();
                string sql1 = string.Format("SELECT SUM(Point{0}) FROM bx_PointLogs WHERE  Point{0} > 0 ", pointIndex);
                string sql2 = string.Format("SELECT SUM(Point{0}) FROM bx_PointLogs WHERE  Point{0} < 0 ", pointIndex);
                string sql0 = string.Format("SELECT SUM(Point_{0}) FROM bx_Users WHERE Point_{0}>0", pointIndex + 1);

                if (!string.IsNullOrEmpty(filter.Username))
                {
                    sb.Append(" AND UserID IN( SELECT UserID FROM bx_Users WHERE Username = @Username )");
                    query.CreateParameter<string>("@Username", filter.Username, SqlDbType.NVarChar, 50);
                    sql2 += " AND Username = @Username;";
                }

                if (filter.OperateID != null)
                {
                    sb.Append(" AND OperateID = @OperateID");
                    query.CreateParameter<int>("@OperateID", filter.OperateID.Value, SqlDbType.Int);
                }

                if (filter.BeginDate != null)
                {
                    sb.Append(" AND CreateTime >= @BeginDate");
                    query.CreateParameter<DateTime>("@BeginDate", filter.BeginDate.Value, SqlDbType.DateTime);
                }

                if (filter.EndDate != null)
                {
                    sb.Append(" AND CreateTime <= @EndDate");
                    query.CreateParameter<DateTime>("@EndDate", filter.EndDate.Value, SqlDbType.DateTime);
                }

                sql1 += sb;
                sql2 += sb;
                string sql = string.Format("{0};{1};{2};", sql0, sql1, sql2);

                query.CommandText = sql;
                count = 0;
                produceCount = 0;
                consumeCount = 0;

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    while (reader.Next)
                        count = reader.Get<int>(0);
                    if (reader.NextResult())
                    {
                        while (reader.Next)
                            produceCount = reader.Get<int>(0);

                        if (reader.NextResult())
                            while (reader.Next)
                                consumeCount = reader.Get<int>(0);
                    }
                }
            }
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:59,代码来源:PointLogDao.cs

示例8: GetAnnouncements

 /// <summary>
 /// 取得所有公告
 /// </summary>
 /// <returns></returns>
 public override AnnouncementCollection GetAnnouncements()
 {
     using (SqlQuery query = new SqlQuery())
     {
         query.CommandText = "SELECT * FROM bx_Announcements ORDER BY SortOrder ASC, BeginDate ASC";
         using (XSqlDataReader reader = query.ExecuteReader())
         {
             return new AnnouncementCollection(reader);
         }
     }
 }
开发者ID:huchao007,项目名称:bbsmax,代码行数:15,代码来源:AnnouncementDao.cs

示例9: GetPointLogTypes

        public override Entities.PointLogTypeCollection GetPointLogTypes()
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "SELECT * FROM bx_PointLogTypes";

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    return new PointLogTypeCollection(reader);
                }
            }
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:12,代码来源:PointLogDao.cs

示例10: GetAllRoles

 public override RoleCollection GetAllRoles()
 {
     using (SqlQuery query = new SqlQuery())
     {
         query.CommandText = "SELECT * FROM bx_Roles";
         using (XSqlDataReader reader = query.ExecuteReader())
         {
             RoleCollection rolegroups = new RoleCollection(reader);
             return rolegroups;
         }
     }
 }
开发者ID:huchao007,项目名称:bbsmax,代码行数:12,代码来源:RoleDao.cs

示例11: GetFeedTemplates

 public override FeedTemplateCollection GetFeedTemplates()
 {
     using (SqlQuery query = new SqlQuery())
     {
         query.CommandText = "bx_GetFeedTemplates";
         query.CommandType = CommandType.StoredProcedure;
         using (XSqlDataReader reader = query.ExecuteReader())
         {
             return new FeedTemplateCollection(reader);
         }
     }
 }
开发者ID:huchao007,项目名称:bbsmax,代码行数:12,代码来源:FeedDao.cs

示例12: GetClubCategories

        public override ClubCategoryCollection GetClubCategories()
        {
            using (SqlQuery db = new SqlQuery())
            {
                db.CommandText = "bx_Club_GetClubCategories";
                db.CommandType = System.Data.CommandType.StoredProcedure;

                using (XSqlDataReader reader = db.ExecuteReader())
                {
                    return new ClubCategoryCollection(reader);
                }
            }
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:13,代码来源:ClubDao.cs

示例13: GetUserPays

        public override UserPayCollection GetUserPays(int userID, PaylogFilter filter, int pageSize, int pageNumber)
        {
            using (SqlQuery query = new SqlQuery())
            {
                StringBuilder condition = new StringBuilder(" AND UserID = @UserID");
                query.CreateParameter<int>("@UserID", userID, SqlDbType.Int);
                
                if (filter != null)
                {
                    if (filter.State < 2)
                    {
                        condition.Append(" AND [email protected]");
                        query.CreateParameter<bool>("@State", (filter.State == 1), SqlDbType.Bit);
                    }
                    if (filter.BeginDate != null)
                    {
                        condition.Append(" AND PayDate>= @BeginDate");
                        query.CreateParameter<DateTime>("@BeginDate", filter.BeginDate.Value, SqlDbType.DateTime);
                    }

                    if (filter.EndDate != null)
                    {
                        condition.Append(" AND PayDate<= @EndDate");
                        query.CreateParameter<DateTime>("@EndDate", filter.EndDate.Value, SqlDbType.DateTime);
                    }

                }
                if (condition.Length > 5)
                    condition.Remove(0, 5);

                query.Pager.TableName = "bx_Pay";
                query.Pager.PageSize = pageSize;
                query.Pager.PageNumber = pageNumber;
                query.Pager.PrimaryKey = "PayID";
                query.Pager.SelectCount = true;
                query.Pager.SortField = "PayID";
                query.Pager.Condition = condition.ToString();
                query.Pager.IsDesc = true;
                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    UserPayCollection result = new UserPayCollection(reader);
                    if (reader.NextResult())
                    {
                        while (reader.Next)
                            result.TotalRecords = reader.Get<int>(0);
                    }

                    return result;
                }
            }
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:51,代码来源:PayDao.cs

示例14: GetAllBannedUsers

        public override BannedUserCollection GetAllBannedUsers()
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_GetAllBannedUsers";
                query.CommandType = CommandType.StoredProcedure;

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    return new BannedUserCollection(reader);
                }

            }
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:14,代码来源:BannedUserDao.cs

示例15: GetUserBlogTags

		private TagCollection GetUserBlogTags(int userID)
		{
			using (SqlQuery db = new SqlQuery())
			{
				db.CommandText = "bx_Tag_GetUserBlogTags";
				db.CommandType = CommandType.StoredProcedure;

				db.CreateParameter<int>("@UserID", userID, SqlDbType.Int);

				using (XSqlDataReader reader = db.ExecuteReader())
				{
                    return new TagCollection(reader);
				}
			}
		}
开发者ID:huchao007,项目名称:bbsmax,代码行数:15,代码来源:TagDao.cs


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