示例#1
0
        public void DBRead(int gameId, bool readRoms = false)
        {
            if (_commandRvGameRead == null)
            {
                _commandRvGameRead = new SQLiteCommand(@"
                SELECT GameId, DatId, name, description, manufacturer, cloneof, romof, sourcefile, isbios, board, year, istrurip, publisher, developer, edition, version, type, media, language, players, ratings, genre, peripheral, barcode, mediacatalognumber
                    FROM GAME WHERE GameId=@GameId ORDER BY name", DBSqlite.db.Connection);
                _commandRvGameRead.Parameters.Add(new SQLiteParameter("GameId"));
            }

            _commandRvGameRead.Parameters["GameId"].Value = gameId;

            using (DbDataReader dr = _commandRvGameRead.ExecuteReader())
            {
                if (dr.Read())
                {
                    RvGameReadFromReader(dr, this);
                }

                dr.Close();
            }

            if (readRoms)
            {
                Roms = RvRom.ReadRoms(GameId);
            }
        }
示例#2
0
        public static List <RvGame> ReadGames(uint datId, bool readRoms = false)
        {
            if (_commandRvGameReadDatGames == null)
            {
                _commandRvGameReadDatGames = new SQLiteCommand(@"
                SELECT GameId, DatId, name, description, manufacturer, cloneof, romof, sourcefile, isbios, board, year, istrurip, publisher, developer, edition, version, type, media, language, players, ratings, genre, peripheral, barcode, mediacatalognumber
                    FROM GAME WHERE DatId=@DatId ORDER BY name", DBSqlite.db.Connection);
                _commandRvGameReadDatGames.Parameters.Add(new SQLiteParameter("DatId"));
            }

            List <RvGame> games = new List <RvGame>();

            _commandRvGameReadDatGames.Parameters["DatId"].Value = datId;

            using (DbDataReader dr = _commandRvGameReadDatGames.ExecuteReader())
            {
                while (dr.Read())
                {
                    RvGame rvGame = new RvGame();
                    RvGameReadFromReader(dr, rvGame);
                    games.Add(rvGame);
                }
                dr.Close();
            }

            if (readRoms)
            {
                foreach (RvGame game in games)
                {
                    game.Roms = RvRom.ReadRoms(game.GameId);
                }
            }

            return(games);
        }