public void TestMapping() { QueryClassRelation relation = new QueryClassRelation().SetId(3); ClientQuery clientQuery = ClientQuery.For <QueryClass>() .Add((QueryClass q) => q.Name == "test name") .Add((QueryClass q) => q.Type == QueryClassType.First) .Add((QueryClass q) => q.RelatedTo == relation); DetachedCriteria criteria = DetachedCriteria.For <QueryClass>() .Add((QueryClass q) => q.Name == "test name") .Add((QueryClass q) => q.Type == QueryClassType.First) .Add((QueryClass q) => q.RelatedTo == relation); DetachedCriteria convertedCriteria = ClientQueryConverter.ToDetachedCriteria(clientQuery); Assert.AreEqual(criteria.EntityOrClassName, convertedCriteria.EntityOrClassName); Assert.AreEqual(criteria.ToString(), convertedCriteria.ToString()); }
public IList <T> get_transformation_with_criteria <T>(DetachedCriteria detachedCriteria) { if (detachedCriteria == null) { Log.bound_to(this).Warn( "Please ensure you send in a criteria when you want to get transformed records. Otherwise please consider using GetAll(). Returning empty list."); return(null); } IList <T> list; using (ISession session = session_factory.OpenSession()) { ICriteria criteria = detachedCriteria.GetExecutableCriteria(session); list = criteria .SetResultTransformer(new AliasToBeanResultTransformer(typeof(T))) .List <T>(); session.Close(); } Log.bound_to(this).Info("Repository found {0} records of type {1} with criteria {2}.", list.Count, typeof(T).Name, detachedCriteria.ToString()); return(list); }
public IList <T> get_transformation_with_criteria <T>(DetachedCriteria detachedCriteria) { if (detachedCriteria == null) { Log.bound_to(this).log_a_warning_event_containing("Please ensure you send in a criteria when you want to get transformed records. Otherwise please consider using GetAll(). Returning empty list."); return(null); } IList <T> list; bool running_long_session = session == null; if (!running_long_session) { start(false); } ICriteria criteria = detachedCriteria.GetExecutableCriteria(session); list = criteria .SetResultTransformer(new AliasToBeanResultTransformer(typeof(T))) .List <T>(); if (!running_long_session) { finish(); } 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.ToString()); return(list); }
public IList <T> get_with_criteria <T>(DetachedCriteria detachedCriteria) { 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; bool not_running_outside_session = session == null; if (not_running_outside_session) { start(false); } ICriteria criteria = detachedCriteria.GetExecutableCriteria(session); list = criteria.List <T>(); if (not_running_outside_session) { finish(); } 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.ToString()); return(list); }