/// <summary> /// Creates a new DetachedNamedQuery that is a deep copy of the current instance. /// </summary> /// <returns>The clone.</returns> public DetachedNamedQuery Clone() { var result = new DetachedNamedQuery(queryName); CopyTo(result); return(result); }
/// <summary> /// /// </summary> /// <param name="queryRowsCount"></param> public NamedQueryRowsCounter(string queryRowsCount) { if (string.IsNullOrEmpty(queryRowsCount)) { throw new ArgumentNullException("queryRowsCount"); } dq = new DetachedNamedQuery(queryRowsCount); }
public NamedQueryRowsCounter(DetachedNamedQuery queryRowsCount) { if (queryRowsCount == null) { throw new ArgumentNullException("queryRowsCount"); } dq = queryRowsCount; }
public void RowsCountUsingParameters() { DetachedNamedQuery q = new DetachedNamedQuery("Foo.Count.Parameters"); q.SetString("p1", "%1_"); IRowsCounter rc = new NamedQueryRowsCounter(q); using (ISession s = OpenSession()) { Assert.AreEqual(5, rc.GetRowsCount(s)); } }
/// <summary> /// Creates a new DetachedNamedQuery that is a deep copy of the current instance. /// </summary> /// <returns>The clone.</returns> public DetachedNamedQuery Clone() { DetachedNamedQuery result = new DetachedNamedQuery(queryName); CopyTo(result); return result; }
public void ResultTransformer() { IDetachedQuery dq = new DetachedNamedQuery("NoFoo.SQL.Parameters"); dq.SetString("p1", "%1_") .SetResultTransformer(new AliasToBeanResultTransformer(typeof(NoFoo))); using (ISession s = OpenSession()) { IQuery q = dq.GetExecutableQuery(s); IList<NoFoo> l = q.List<NoFoo>(); Assert.AreEqual(5, l.Count); } }
public void ExecutableNamedQuery() { IDetachedQuery dq = new DetachedNamedQuery("Foo.WithParameters"); dq.SetString("pn", "N2"); using (ISession s = OpenSession()) { IQuery q = dq.GetExecutableQuery(s); IList<Foo> l = q.List<Foo>(); Assert.AreEqual(1, l.Count); Assert.AreEqual("N2", l[0].Name); Assert.AreEqual("D2", l[0].Description); } // reusing same IDetachedQuery dq.SetString("pn", "@All@"); using (ISession s = OpenSession()) { IQuery q = dq.GetExecutableQuery(s); IList l = q.List(); Assert.AreEqual(totalFoo, l.Count); } }
/// <summary> /// /// </summary> /// <param name="origin"></param> /// <returns></returns> public IRowsCounter CopyParametersFrom(DetachedNamedQuery origin) { origin.SetParametersTo(dq); return this; }
public NamedQueryRowsCounter(string queryRowsCount, DetachedNamedQuery origin) : this(queryRowsCount) { this.origin = origin; }