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

DeleteAll() protected static method

Deletes all rows for the specified ActiveRecord type that matches the supplied HQL condition
This method is usually useful for test cases.
protected static DeleteAll ( Type type, String where ) : void
type System.Type ActiveRecord type on which the rows on the database should be deleted
where String HQL condition to select the rows to be deleted
return void
		protected internal static void DeleteAll(Type type, String where)
		{
			EnsureInitialized(type);

			ISession session = holder.CreateSession(type);

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

				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 ) : void

Usage Example

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