Beispiel #1
0
        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());
        }
Beispiel #2
0
 public ModelSelect(SQLSelect select)
 {
     this.selectInstance = select;
     this.info           = Model.GetInfo <T>();
 }
Beispiel #3
0
        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)));
        }
Beispiel #4
0
        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);
        }