Example #1
0
		public EntityStore(string databaseFullPath, DestructorType destructorType = DestructorType.None)
		{
			_databaseFullPath = databaseFullPath;
			_destructorType = destructorType;
			_connectionString = String.Format("Data Source={0}; Version=3; Read Only=False; Pooling=True; Max Pool Size=10", _databaseFullPath);
			
			if (!File.Exists(_databaseFullPath))
			{
				SQLiteConnection.CreateFile(_databaseFullPath);
				Log.Info("Successfully created the EntityStore database file at {0}", databaseFullPath);
			}
			else
			{
				Log.Info("Successfully confirmed that the EntityStore database exists at {0}", databaseFullPath);
			}

			using (var connection = new SQLiteConnection(_connectionString))
			{
				connection.Open();
				using (var cmd = connection.CreateCommand())
				{
					Log.Verbose("About to create or check for the Entities table in the EntityStore database.");
					cmd.CommandText = "CREATE TABLE IF NOT EXISTS Entities (entityType TEXT, entityKey TEXT, entityBlob TEXT, entityTag TEXT, lastModified DATETIME, PRIMARY KEY (entityType, entityKey))";
					cmd.CommandType = CommandType.Text;
					cmd.ExecuteNonQuery();
					Log.Info("Successfully created or checked that the Entities table exists in the EntityStore database.");
				}
			}
		}
Example #2
0
        public EntityStore(string databaseFullPath, DestructorType destructorType = DestructorType.None)
        {
            _databaseFullPath = databaseFullPath;
            _destructorType   = destructorType;
            _connectionString = String.Format("Data Source={0}; Version=3; Read Only=False; Pooling=True; Max Pool Size=10", _databaseFullPath);

            if (!File.Exists(_databaseFullPath))
            {
                SQLiteConnection.CreateFile(_databaseFullPath);
                Log.Info("Successfully created the EntityStore database file at {0}", databaseFullPath);
            }
            else
            {
                Log.Info("Successfully confirmed that the EntityStore database exists at {0}", databaseFullPath);
            }

            using (var connection = new SQLiteConnection(_connectionString))
            {
                connection.Open();
                using (var cmd = connection.CreateCommand())
                {
                    Log.Verbose("About to create or check for the Entities table in the EntityStore database.");
                    cmd.CommandText = "CREATE TABLE IF NOT EXISTS Entities (entityType TEXT, entityKey TEXT, entityBlob TEXT, entityTag TEXT, lastModified DATETIME, PRIMARY KEY (entityType, entityKey))";
                    cmd.CommandType = CommandType.Text;
                    cmd.ExecuteNonQuery();
                    Log.Info("Successfully created or checked that the Entities table exists in the EntityStore database.");
                }
            }
        }
Example #3
0
 public ModelStore(string databaseFullPath, DestructorType destructorType = DestructorType.None)
     : base(databaseFullPath, destructorType)
 {
 }