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

Execute() protected static method

Invokes the specified delegate passing a valid NHibernate session. Used for custom NHibernate queries.
protected static Execute ( Type targetType, NHibernateDelegate call, object instance ) : object
targetType System.Type The target ActiveRecordType
call NHibernateDelegate The delegate instance
instance object The ActiveRecord instance
return object
		protected internal static object Execute(Type targetType, NHibernateDelegate call, object instance)
		{
			if (targetType == null) throw new ArgumentNullException("targetType", "Target type must be informed");
			if (call == null) throw new ArgumentNullException("call", "Delegate must be passed");

			EnsureInitialized(targetType);

			ISession session = holder.CreateSession(targetType);

			try
			{
				return call(session, instance);
			}
			catch (ValidationException)
			{
				holder.FailSession(session);

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

				throw new ActiveRecordException("Error performing Execute for " + targetType.Name, ex);
			}
			finally
			{
				holder.ReleaseSession(session);
			}
		}

Same methods

ActiveRecordBase::Execute ( NHibernateDelegate call ) : object

Usage Example

Ejemplo n.º 1
0
 /// <summary>
 /// Invokes the specified delegate passing a valid
 /// NHibernate session. Used for custom NHibernate queries.
 /// </summary>
 /// <param name="targetType">The target ActiveRecordType</param>
 /// <param name="call">The delegate instance</param>
 /// <param name="instance">The ActiveRecord instance</param>
 /// <returns>Whatever is returned by the delegate invocation</returns>
 public static object Execute(Type targetType, NHibernateDelegate call, object instance)
 {
     return(ActiveRecordBase.Execute(targetType, call, instance));
 }
All Usage Examples Of Castle.ActiveRecord.ActiveRecordBase::Execute