public static int CountQueryResult(QueryOver<Event> query) { using (ISession session = NHibernateHelper.OpenSession()) { return query.GetExecutableQueryOver(session).Select(Projections.Count<Event>(e => e.EventId)).RowCount(); } }
/// <summary> /// <paramref name="queryOver"/> 인스턴스를 <paramref name="session"/>에서 수행할 수 있는 <see cref="IQueryOver{T,T}"/> 를 생성합니다. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="session"></param> /// <param name="queryOver"></param> /// <returns></returns> public static IQueryOver <T, T> GetExecutableQueryOver <T>(this ISession session, QueryOver <T> queryOver) { session.ShouldNotBeNull("session"); queryOver.ShouldNotBeNull("queryOver"); var result = queryOver.GetExecutableQueryOver(session); return(result); }
/// <summary> /// The find one. /// </summary> /// <param name="queryOver"> /// The query over. /// </param> /// <typeparam name="TReturn"> /// Returned object type /// </typeparam> /// <returns> /// The <see cref="IFutureValue{TReturn}"/>. /// </returns> public IFutureValue <TReturn> FindOne <TReturn>(QueryOver <TEntity> queryOver) { if (Session == null) { throw new InvalidOperationException("Session is null"); } return(queryOver.GetExecutableQueryOver(Session).FutureValue <TReturn>()); }
public IEnumerable <Item> get_all_items_matching <Item>(Query <Item> query) { if (query == null) { throw new ArgumentNullException(); } if (query is QueryImplByQueryOver <Item> ) { QueryOver <Item> my_query = (query as QueryImplByQueryOver <Item>).Query; return(my_query.GetExecutableQueryOver(session).List()); } throw new ArgumentException( string.Format("Query {0} is not type supported.", query.GetType())); }
public override MembershipUser GetUser(string username, bool userIsOnline) { MembershipUser outp = null; QueryOver <User> q = QueryOver .Of <User>() .Where(c => c.Username == username); User u = null; if (q != null) { u = q.GetExecutableQueryOver(currentSession).SingleOrDefault(); } if (u != null) { outp = new WallMembershipUser(u.Username, u.Password); } return(outp); }
public IList <T> get_with_criteria <T>(QueryOver <T> detachedCriteria) where T : class { if (detachedCriteria == null) { Log.bound_to(this).log_a_warning_event_containing("Please ensure you send in a criteria when you want to limit records. Otherwise please consider using GetAll(). Returning empty list."); return(null); } IList <T> list; using (ensure_session_started()) { IQueryOver <T, T> criteria = detachedCriteria.GetExecutableQueryOver(session); list = criteria.List <T>(); } Log.bound_to(this).log_a_debug_event_containing("Repository found {0} records of type {1} with criteria {2}.", list.Count, typeof(T).Name, detachedCriteria.to_string()); return(list); }
public void DetachedQuery_SimpleCriterion() { using (ISession s = OpenSession()) using (ITransaction t = s.BeginTransaction()) { s.Save(new Person() { Name = "test person 1", Age = 20 }); t.Commit(); } using (ISession s = OpenSession()) { QueryOver<Person> personQuery = new QueryOver<Person>() .Where(p => p.Name == "test person 1"); IList<Person> actual = personQuery.GetExecutableQueryOver(s) .List(); Assert.That(actual[0].Age, Is.EqualTo(20)); } }
public IQueryOver <T, T> QueryOver <T>(QueryOver <T> detachedQuery) where T : EntityBase { var query = detachedQuery.GetExecutableQueryOver(Session); return(query); }
/// <summary> /// The find one. /// </summary> /// <param name="queryOver"> /// The query over. /// </param> /// <typeparam name="TReturn"> /// Returned object type /// </typeparam> /// <returns> /// The <see cref="IFutureValue{TReturn}"/>. /// </returns> public IFutureValue <TReturn> FindOne <TReturn>(QueryOver <TEntity> queryOver) { return(queryOver.GetExecutableQueryOver(this.Manager.Session).FutureValue <TReturn>()); }
/// <summary> /// The find all. /// </summary> /// <typeparam name="TOtherEntity"> /// The other entity type /// </typeparam> /// <param name="queryOver"> /// The query over. /// </param> /// <returns> /// The <see cref="IEnumerable{T}"/>. /// </returns> public IEnumerable <TOtherEntity> FindAll <TOtherEntity>(QueryOver <TEntity> queryOver) { return(queryOver.GetExecutableQueryOver(this.Manager.Session).Future <TOtherEntity>()); }
public IQueryOver <T1, T1> ExecuteQuery <T1, T2>(QueryOver <T1, T2> query) where T1 : class where T2 : class { return(query.GetExecutableQueryOver(dbSession)); }
public IQueryOver <T> ExecuteQuery <T>(QueryOver <T> query) where T : class { return(query.GetExecutableQueryOver(dbSession)); }
public static IList<Event> GetQueryResult(int skip, int maxRow, QueryOver<Event> query) { using (ISession session = NHibernateHelper.OpenSession()) { return query.GetExecutableQueryOver(session).Skip(skip).Take(maxRow).List(); } }
/// <summary> /// The find all. /// </summary> /// <param name="queryOver"> /// The query over. /// </param> /// <returns> /// The <see cref="IEnumerable{T}"/>. /// </returns> public IEnumerable <TEntity> FindAll(QueryOver <TEntity> queryOver) { return(queryOver.GetExecutableQueryOver(Session).Future <TEntity>()); }