Allow programmers to use the ActiveRecord functionality without direct reference to ActiveRecordBase
Ejemplo n.º 1
0
 private static void VerifySchema(ActiveRecordModelCollection models)
 {
     foreach (ActiveRecordModel model in models)
     {
         if (!model.Type.IsAbstract)
         {
             try
             {
                 ActiveRecordMediator.FindAll(model.Type, Expression.Sql("1=0"));
             }
             catch (Exception ex)
             {
                 throw new ActiveRecordException("Error verifying the schema for model " + model.Type.Name, ex);
             }
         }
     }
 }
 /// <summary>
 /// Refresh the instance from the database.
 /// </summary>
 /// <param name="instance">The ActiveRecord instance to be reloaded</param>
 public static void Refresh(T instance)
 {
     ActiveRecordMediator.Refresh(instance);
 }
 /// <summary>
 /// Deletes the instance from the database.
 /// </summary>
 /// <param name="instance"></param>
 public static void Delete(T instance)
 {
     ActiveRecordMediator.Delete(instance);
 }
 /// <summary>
 /// Persists the modification on the instance
 /// state to the database.
 /// </summary>
 /// <param name="instance"></param>
 public static void Update(T instance)
 {
     ActiveRecordMediator.Update(instance);
 }
 /// <summary>
 /// Creates (Saves) a new instance to the database.
 /// </summary>
 /// <param name="instance"></param>
 public static void Create(T instance)
 {
     ActiveRecordMediator.Create(instance);
 }
 /// <summary>
 /// Saves a copy of the instance to the database
 /// </summary>
 /// <param name="instance"></param>
 /// <returns>The saved instance</returns>
 public static T SaveCopy(T instance)
 {
     return((T)ActiveRecordMediator.SaveCopy(instance));
 }
 /// <summary>
 /// Saves the instance to the database
 /// </summary>
 /// <param name="instance"></param>
 public static void Save(T instance)
 {
     ActiveRecordMediator.Save(instance);
 }