Castle.ActiveRecord.ActiveRecordBase.DeleteAll C# (CSharp) Method

DeleteAll() protected static method

Deletes all rows for the specified ActiveRecord type
This method is usually useful for test cases.
protected static DeleteAll ( Type type ) : void
type System.Type ActiveRecord type on which the rows on the database should be deleted
return void
		protected internal static void DeleteAll(Type type)
		{
			EnsureInitialized(type);

			ISession session = holder.CreateSession(type);

			try
			{
				session.Delete(String.Format("from {0}", type.Name));

				session.Flush();
			}
			catch (ValidationException)
			{
				holder.FailSession(session);

				throw;
			}
			catch (Exception ex)
			{
				holder.FailSession(session);

				throw new ActiveRecordException("Could not perform DeleteAll for " + type.Name, ex);
			}
			finally
			{
				holder.ReleaseSession(session);
			}
		}

Same methods

ActiveRecordBase::DeleteAll ( Type targetType, IEnumerable pkValues ) : int
ActiveRecordBase::DeleteAll ( Type type, String where ) : void

Usage Example

Ejemplo n.º 1
0
 public static void DeleteAll()
 {
     ActiveRecordBase.DeleteAll(typeof(T));
 }
All Usage Examples Of Castle.ActiveRecord.ActiveRecordBase::DeleteAll