示例#1
0
 public DbConnection GetConnection()
 {
     DbConnection connection = Factory.CreateConnection();
     connection.ConnectionString = string.Format("Data Source = {0}", Path);
     connection.Open();
     //Turn on SQLite foreign keys
     using (var pragma = new DatabaseCommand("pragma foreign_keys = on", connection))
     {
         pragma.Execute();
     }
     return connection;
 }
示例#2
0
        void InitialiseSummonerCache()
        {
            SummonerCache = new Dictionary<RegionType, Dictionary<int, Summoner>>();

            foreach (RegionType regionType in Enum.GetValues(typeof(RegionType)))
                SummonerCache[regionType] = new Dictionary<int, Summoner>();

            using (var connection = Provider.GetConnection())
            {
                using (var select = new DatabaseCommand("select {0} from summoner", connection, null, Summoner.GetFields()))
                {
                    using (var reader = select.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Summoner summoner = new Summoner(reader);
                            SummonerCache[summoner.Region][summoner.AccountId] = summoner;
                        }
                    }
                }
            }
        }
 public void CopyParameters(DatabaseCommand command)
 {
     DbParameter[] parameters = new DbParameter[command.Command.Parameters.Count];
     command.Command.Parameters.CopyTo(parameters, 0);
     Command.Parameters.AddRange(parameters);
 }