public PlayerRaiderRoundHistoryRecordInfo[] GetPlayerRaiderRoundHistoryRecordInfo(int userID, int pageItemCount, int pageIndex) { MySqlConnection myconn = null; MySqlCommand mycmd = null; try { myconn = MyDBHelper.Instance.CreateConnection(); string sqlOrderLimit = " order by b.RaiderRoundID desc "; if (pageItemCount > 0) { int start = pageIndex <= 0 ? 0 : (pageIndex - 1) * pageItemCount; sqlOrderLimit += " limit " + start.ToString() + ", " + pageItemCount; } string sqlTextA = "select ttt.*, r.* from " + " (SELECT b.RaiderRoundID, sum(b.BetStones) as AllBetStones " + " FROM raiderplayerbetinfo b " + " where b.UserID = @UserID " + " group by b.RaiderRoundID " + sqlOrderLimit + " ) ttt " + " left join raiderroundmetadatainfo r on ttt.RaiderRoundID = r.id "; mycmd = myconn.CreateCommand(); mycmd.CommandText = sqlTextA; mycmd.Parameters.AddWithValue("@UserID", userID); myconn.Open(); DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(mycmd); adapter.Fill(table); var lists = MetaDBAdapter <PlayerRaiderRoundHistoryRecordInfo> .GetPlayerRaiderRoundHistoryRecordInfoFromDataTable(table); table.Clear(); table.Dispose(); adapter.Dispose(); return(lists); } finally { if (mycmd != null) { mycmd.Dispose(); } if (myconn != null) { myconn.Close(); myconn.Dispose(); } } }