public bool Delete() { ModelInfo info = GetInfo(this.GetType()); if (info.PrimaryField == null) { throw new ModelFormatException("Could not delete, Model does not contain a Primary Key."); } object primaryVal = info.PrimaryField.GetInfo().GetValue(this); if (primaryVal == null) { throw new InvalidOperationException("Could not delete, Model Primary Key is null"); } return(Database.PrimaryDB.Delete(info.Table.Name) .Where(info.PrimaryField.GetField(), primaryVal) .Execute()); }
public ModelSelect(SQLSelect select) { this.selectInstance = select; this.info = Model.GetInfo <T>(); }
public static ModelSelect <T> Select <T>(params string[] fields) where T : Model { ModelInfo info = GetInfo <T>(); return(new ModelSelect <T>(Database.PrimaryDB.Select(info.Table.Name, fields))); }
public static bool BuildSchema <T>(int level, Database db) where T : Model { ModelInfo info = GetInfo <T>(); return(false); // db.BuildSchema(info.table.table, info.fillables); }