Beispiel #1
0
 public IList <Person> GetByDocumentStart(int start)
 {
     return(factory.GetCurrentSession()
            .CreateCriteria <Person>()
            .Add(Criterion.StartsWith("Document", start))
            .List <Person>());
 }
        public void StartsWithTest()
        {
            using (ISession session = OpenSession())
            {
                var criteria      = (CriteriaImpl)session.CreateCriteria(typeof(Simple));
                var criteriaQuery = new CriteriaQueryTranslator(sessions, criteria, criteria.EntityOrClassName, "sql_alias");

                ICriterion exp       = Criterion.StartsWith("Number", "2");
                SqlString  sqlString = exp.ToSqlString(criteria, criteriaQuery, new CollectionHelper.EmptyMapClass <string, IFilter>());

                string expectedSql = "sql_alias.Number like ?";

                Assert.AreEqual(expectedSql, sqlString.ToString());
                Assert.AreEqual(1, sqlString.GetParameterCount());
            }
        }