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

ExecuteQuery() public static method

Executes the query.
public static ExecuteQuery ( IActiveRecordQuery query ) : object
query IActiveRecordQuery The query.
return object
		public static object ExecuteQuery(IActiveRecordQuery query)
		{
			Type rootType = query.RootType;

			EnsureInitialized(rootType);

			ISession session = holder.CreateSession(rootType);

			try
			{
				return query.Execute(session);
			}
			catch (Exception ex)
			{
				holder.FailSession(session);

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

Usage Example

Beispiel #1
0
 //This may return more than one result, and more than one type,
 //so this is here just to complement the non-generic version, instead of
 //enhancing it, like the rest of the methods here.
 public static object ExecuteQuery(IActiveRecordQuery q)
 {
     return(ActiveRecordBase.ExecuteQuery(q));
 }