You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/ZeroLevel.EventServer/EventRepository.cs

30 lines
885 B

5 years ago
using System;
using System.Collections.Generic;
using System.Data.SQLite;
using System.Text;
using System.Threading;
using ZeroLevel.SqLite;
namespace ZeroLevel.EventServer
{
public class EventRepository
:BaseSqLiteDB
{
private readonly SQLiteConnection _db;
private readonly ReaderWriterLockSlim _rwLock = new ReaderWriterLockSlim();
private readonly string _tableName;
public EventRepository()
{
_tableName = "events";
var path = PrepareDb($"{_tableName}.db");
_db = new SQLiteConnection($"Data Source={path};Version=3;");
_db.Open();
Execute($"CREATE TABLE IF NOT EXISTS {_tableName} (id INTEGER PRIMARY KEY AUTOINCREMENT, key TEXT, body BLOB)", _db);
Execute($"CREATE INDEX IF NOT EXISTS key_index ON {_tableName} (key)", _db);
}
}
}

Powered by TurnKey Linux.