Performs the framework initialization.
This class is not thread safe.
Пример #1
0
        ///<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);
        }
Пример #2
0
 /// <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));
 }
Пример #3
0
 /// <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));
 }
Пример #4
0
 /// <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));
 }
Пример #5
0
 /// <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));
 }
Пример #6
0
 /// <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>());
 }
Пример #7
0
 /// <summary>
 /// Evict the instance from scope session
 /// </summary>
 public virtual void Evict()
 {
     AR.CurrentScope().Evict <T>(this as T);
 }
Пример #8
0
 /// <summary>
 /// Refresh the instance from the database.
 /// </summary>
 public virtual void Refresh()
 {
     AR.CurrentScope().Refresh(this as T);
 }
Пример #9
0
 /// <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);
 }
Пример #10
0
 /// <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);
 }
Пример #11
0
 /// <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);
 }
Пример #12
0
 /// <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));
 }
Пример #13
0
 /// <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));
 }
Пример #14
0
 /// <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));
 }
Пример #15
0
 /// <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));
 }
Пример #16
0
 /// <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);
 }
Пример #17
0
 /// <summary>
 /// Deletes the instance from the database.
 /// </summary>
 public virtual void Delete(bool flush = true)
 {
     AR.CurrentScope().Delete(this as T, flush);
 }
Пример #18
0
 /// <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);
 }
Пример #19
0
 /// <summary>
 /// Merge the instance to scope session
 /// </summary>
 public virtual void Merge()
 {
     AR.CurrentScope().Merge(this as T);
 }
Пример #20
0
 /// <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);
 }
Пример #21
0
 /// <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);
 }
Пример #22
0
 /// <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);
 }
Пример #23
0
 /// <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));
 }
Пример #24
0
 /// <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);
 }
Пример #25
0
 /// <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));
 }
Пример #26
0
 /// <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));
 }
Пример #27
0
 /// <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));
 }
Пример #28
0
 /// <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));
 }
Пример #29
0
 /// <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));
 }
Пример #30
0
 /// <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));
 }