Performs the framework initialization.
This class is not thread safe.
        ///<summary>
        /// This method allows direct registration of Configuration
        ///</summary>
        public virtual void RegisterConfiguration(Configuration cfg, string name)
        {
            var sf       = cfg.BuildSessionFactory();
            var sfholder = new SfHolder(cfg, sf);

            foreach (var classMetadata in sf.GetAllClassMetadata())
            {
                var entitytype = classMetadata.Value.GetMappedClass(EntityMode.Poco);

                if (Type2SessFactory.ContainsKey(entitytype))
                {
                    throw new ActiveRecordException("Type has already been registered -> " + entitytype.FullName);
                }

                Type2SessFactory.Add(entitytype, sfholder);
            }
            AR.RaiseSessionFactoryCreated(sf, cfg, name);
        }
 /// <summary>
 /// Returns a portion of the query results (sliced)
 /// </summary>
 /// <param name="firstResult">The number of the first row to retrieve.</param>
 /// <param name="maxResults">The maximum number of results retrieved.</param>
 /// <param name="criteria">The criteria expression</param>
 /// <returns>The sliced query results.</returns>
 public static IEnumerable <T> SlicedFindAll(int firstResult, int maxResults, params ICriterion[] criteria)
 {
     return(AR.CurrentScope().SlicedFindAll <T>(firstResult, maxResults, criteria));
 }
 /// <summary>
 /// Check if any instance matching the criteria exists in the database.
 /// </summary>
 /// <param name="expression">The queryover expression</param>
 /// <returns><c>true</c> if an instance is found; otherwise <c>false</c>.</returns>
 public static bool Exists(Expression <Func <T, bool> > expression)
 {
     return(AR.CurrentScope().Exists <T>(expression));
 }
 /// <summary>
 /// Check if any instance matches the query.
 /// </summary>
 /// <param name="detachedQuery">The query expression</param>
 /// <returns><c>true</c> if an instance is found; otherwise <c>false</c>.</returns>
 public static bool Exists(IDetachedQuery detachedQuery)
 {
     return(AR.CurrentScope().Exists <T>(detachedQuery));
 }
 /// <summary>
 /// The QueryOver method is used as a Linq collection
 /// or as the in argument in a Linq expression.
 /// </summary>
 /// <remarks>You must have an open Session Scope.</remarks>
 public static IQueryOver <T, T> QueryOver(string entityname)
 {
     return(AR.CurrentScope().QueryOver <T>(entityname));
 }
 /// <summary>
 /// The QueryOver method is used as a Linq collection
 /// or as the in argument in a Linq expression.
 /// </summary>
 /// <remarks>You must have an open Session Scope.</remarks>
 public static IQueryOver <T, T> QueryOver()
 {
     return(AR.CurrentScope().QueryOver <T>());
 }
 /// <summary>
 /// Evict the instance from scope session
 /// </summary>
 public virtual void Evict()
 {
     AR.CurrentScope().Evict <T>(this as T);
 }
 /// <summary>
 /// Refresh the instance from the database.
 /// </summary>
 public virtual void Refresh()
 {
     AR.CurrentScope().Refresh(this as T);
 }
 /// <summary>
 /// Deletes all rows for the specified ActiveRecord type that matches
 /// the supplied expression criteria
 /// </summary>
 public static void DeleteAll(Expression <Func <T, bool> > expression)
 {
     AR.CurrentScope().DeleteAll <T>(expression);
 }
 /// <summary>
 /// Deletes all rows for the specified ActiveRecord type that matches
 /// the supplied criteria
 /// </summary>
 public static void DeleteAll(params ICriterion[] criteria)
 {
     AR.CurrentScope().DeleteAll <T>(criteria);
 }
 /// <summary>
 /// Deletes all rows for the specified ActiveRecord type that matches
 /// the supplied criteria
 /// </summary>
 public static void DeleteAll(DetachedCriteria criteria)
 {
     AR.CurrentScope().DeleteAll <T>(criteria);
 }
 /// <summary>
 /// Returns a portion of the query results (sliced)
 /// </summary>
 /// <param name="firstResult">The number of the first row to retrieve.</param>
 /// <param name="maxResults">The maximum number of results retrieved.</param>
 /// <param name="queryover">Queryover</param>
 /// <returns>The sliced query results.</returns>
 public static IEnumerable <T> SlicedFindAll(int firstResult, int maxResults, QueryOver <T, T> queryover)
 {
     return(AR.CurrentScope().SlicedFindAll <T>(firstResult, maxResults, queryover));
 }
 /// <summary>
 /// Returns a portion of the query results (sliced)
 /// </summary>
 /// <param name="firstResult">The number of the first row to retrieve.</param>
 /// <param name="maxResults">The maximum number of results retrieved.</param>
 /// <returns>The sliced query results.</returns>
 /// <param name="detachedQuery">The query expression</param>
 public static IEnumerable <T> SlicedFindAll(int firstResult, int maxResults, IDetachedQuery detachedQuery)
 {
     return(AR.CurrentScope().SlicedFindAll <T>(firstResult, maxResults, detachedQuery));
 }
 /// <summary>
 /// Finds an object instance by its primary key
 /// returns null if not found
 /// </summary>
 /// <param name="id">Identifier value</param>
 public static T Find(object id)
 {
     return(AR.CurrentScope().Find <T>(id));
 }
 /// <summary>
 /// Returns a portion of the query results (sliced)
 /// </summary>
 /// <param name="firstResult">The number of the first row to retrieve.</param>
 /// <param name="maxResults">The maximum number of results retrieved.</param>
 /// <param name="orders">An <see cref="Array"/> of <see cref="Order"/> objects.</param>
 /// <param name="criteria">The criteria expression</param>
 /// <returns>The sliced query results.</returns>
 public static IEnumerable <T> SlicedFindAll(int firstResult, int maxResults, DetachedCriteria criteria, params Order[] orders)
 {
     return(AR.CurrentScope().SlicedFindAll <T>(firstResult, maxResults, criteria, orders));
 }
 /// <summary>
 /// Persists the modification on the instance
 /// state to the database.
 /// </summary>
 public virtual void Update(bool flush = true)
 {
     AR.CurrentScope().Update(this as T, flush);
 }
 /// <summary>
 /// Deletes the instance from the database.
 /// </summary>
 public virtual void Delete(bool flush = true)
 {
     AR.CurrentScope().Delete(this as T, flush);
 }
 /// <summary>
 /// Deletes all rows for the specified ActiveRecord type that matches
 /// the supplied queryover
 /// </summary>
 public static void DeleteAll(QueryOver <T, T> queryover)
 {
     AR.CurrentScope().DeleteAll <T>(queryover);
 }
 /// <summary>
 /// Merge the instance to scope session
 /// </summary>
 public virtual void Merge()
 {
     AR.CurrentScope().Merge(this as T);
 }
 /// <summary>
 /// Deletes all rows for the specified ActiveRecord type that matches
 /// the supplied HQL condition
 /// </summary>
 /// <param name="where">HQL condition to select the rows to be deleted</param>
 public static void DeleteAll(string where)
 {
     AR.CurrentScope().DeleteAll <T>(where);
 }
 /// <summary>
 /// From NHibernate documentation:
 /// Persist all reachable transient objects, reusing the current identifier
 /// values. Note that this will not trigger the Interceptor of the Session.
 /// </summary>
 /// <param name="replicationMode">The replication mode.</param>
 public virtual void Replicate(ReplicationMode replicationMode)
 {
     AR.CurrentScope().Replicate <T>(this as T, replicationMode);
 }
 /// <summary>
 /// Deletes all <typeparamref name="T"/> objects, based on the primary keys
 /// supplied on <paramref name="pkValues" />.
 /// </summary>
 /// <returns>The number of objects deleted</returns>
 public static void DeleteAll(IEnumerable <object> pkValues)
 {
     AR.CurrentScope().DeleteAll <T>(pkValues);
 }
 /// <summary>
 /// The QueryOver method is used as a Linq collection
 /// or as the in argument in a Linq expression.
 /// </summary>
 /// <remarks>You must have an open Session Scope.</remarks>
 public static IQueryOver <T, T> QueryOver(Expression <Func <T> > alias)
 {
     return(AR.CurrentScope().QueryOver <T>(alias));
 }
 /// <summary>
 /// Saves the instance to the database. If the primary key is unitialized
 /// it creates the instance on the database. Otherwise it updates it.
 /// <para>
 /// If the primary key is assigned, then you must invoke <see cref="Create"/>
 /// or <see cref="Update"/> instead.
 /// </para>
 /// </summary>
 public virtual void Save(bool flush = true)
 {
     AR.CurrentScope().Save(this as T, flush);
 }
 /// <summary>
 /// The QueryOver method is used as a Linq collection
 /// or as the in argument in a Linq expression.
 /// </summary>
 /// <remarks>You must have an open Session Scope.</remarks>
 public static IQueryOver <T, T> QueryOver(string entityname, Expression <Func <T> > alias)
 {
     return(AR.CurrentScope().QueryOver <T>(entityname, alias));
 }
 /// <summary>
 /// Peeks for an object instance by its primary key,
 /// never returns null
 /// </summary>
 /// <param name="id">Identifier value</param>
 public static T Peek(object id)
 {
     return(AR.CurrentScope().Peek <T>(id));
 }
 /// <summary>
 /// Check if any instance matches the criteria.
 /// </summary>
 /// <returns><c>true</c> if an instance is found; otherwise <c>false</c>.</returns>
 public static bool Exists(params ICriterion[] criterias)
 {
     return(AR.CurrentScope().Exists <T>(criterias));
 }
 /// <summary>
 /// Saves a copy of the instance to the database. If the primary key is uninitialized
 /// it creates the instance in the database. Otherwise it updates it.
 /// <para>
 /// If the primary key is assigned, then you must invoke <see cref="Create"/>
 /// or <see cref="Update"/> instead.
 /// </para>
 /// </summary>
 /// <returns>The saved ActiveRecord instance</returns>
 public virtual T SaveCopy(bool flush = true)
 {
     return(AR.CurrentScope().SaveCopy(this as T, flush));
 }
 /// <summary>
 /// Check if any instance matching the criteria exists in the database.
 /// </summary>
 /// <param name="queryover">The queryover expression</param>
 /// <returns><c>true</c> if an instance is found; otherwise <c>false</c>.</returns>
 public static bool Exists(QueryOver <T, T> queryover)
 {
     return(AR.CurrentScope().Exists <T>(queryover));
 }
 /// <summary>
 /// Creates (Saves) a new instance to the database.
 /// </summary>
 public virtual object Create(bool flush = true)
 {
     return(AR.CurrentScope().Create(this as T, flush));
 }