Castle.ActiveRecord.ActiveRecordBase.InternalCreate C# (CSharp) Метод

InternalCreate() приватный статический Метод

Creates (Saves) a new instance to the database.
private static InternalCreate ( object instance, bool flush ) : void
instance object The ActiveRecord instance to be created on the database
flush bool if set to true, the operation will be followed by a session flush.
Результат void
		private static void InternalCreate(object instance, bool flush)
		{
			if (instance == null) throw new ArgumentNullException("instance");

			EnsureInitialized(instance.GetType());

			ISession session = holder.CreateSession(instance.GetType());

			try
			{
				session.Save(instance);

				if (flush)
				{
					session.Flush();
				}
			}
			catch(Exception ex)
			{
				holder.FailSession(session);

				// NHibernate catches our ValidationException, and as such it is the innerexception here
				if (ex.InnerException is ValidationException)
				{
					throw ex.InnerException;
				}
				else
				{
					throw new ActiveRecordException("Could not perform Create for " + instance.GetType().Name, ex);
				}
			}
			finally
			{
				holder.ReleaseSession(session);
			}
		}