public SerializedModel[] GetAll(string model) { string query = CommandString.SelectAll(model); SQLiteDataReader reader = Read(query); return(ReadData(reader, model)); }
public SerializedModel GetById(string model, int id) { string query = CommandString.SelectById(model, id); SQLiteDataReader reader = Read(query); return(ReadData(reader, model)[0]); }
public void AddModel <T>() where T : Model <T> { string name = Model <T> .ModelName; Dictionary <string, Type> fields = Model <T> .GetFields(); string createTable = CommandString.CreateTable(name, fields); Command(createTable); }
public void Save(SerializedModel model) { string update = CommandString.Update( model: model.Name, id: model.Id, fields: model.Data); Command(update); }
public int Create(SerializedModel model) { string name = model.Name; int id = GetId(name); string insert = CommandString.InsertInto( model: name, id: id, fields: model.Data); Command(insert); return(id); }
private int GetId(string model) { string query = CommandString.SelectMaxId(model); SQLiteDataReader reader = Read(query); if (!reader.HasRows) { return(-1); } reader.Read(); try { return(reader.GetInt32(0) + 1); } catch { return(0); } }
public void Remove(string model, int id) { string remove = CommandString.RemoveById(model, id); Command(remove); }