Пример #1
0
        public void AutoComplete(string query, int start, int limit)
        {
            string idQuery = String.Format("{0}%", query);
            string textQuery = String.Format("%{0}%", query);

            DetachedCriteria criteria = DetachedCriteria.For<WaterBody>();
            criteria.Add(Expression.Or(
                Expression.Or(
                    Expression.Like("Name", textQuery),
                    Expression.Like("Abbreviation", textQuery)),
                Expression.Sql("WaterBodyID LIKE '" + idQuery + "'")
            ));
            WaterBody[] results = WaterBody.SlicedFindAll(start, limit, criteria,
                Order.Asc("Name"));

            criteria = DetachedCriteria.For<WaterBody>();
            criteria.Add(Expression.Or(
                Expression.Or(
                    Expression.Like("Name", textQuery),
                    Expression.Like("Abbreviation", textQuery)),
                Expression.Sql("WaterBodyID LIKE '" + idQuery + "'")
            ));
            int count = new ScalarProjectionQuery<WaterBody, int>(
                NHibernate.Expression.Projections.RowCount(),
                criteria
            ).Execute();

            Context.Response.ContentType = "text/javascript";
            RenderText(String.Format("{{ results: {0}, waterbodies: {1} }}", count,
                JavaScriptConvert.SerializeObject(results)));
        }
Пример #2
0
        public void AutoComplete(string query, int start, int limit)
        {
            Logger.Debug(String.Format("XHR call to Watershed Autocomplete for {0} received", query));
            string idQuery = String.Format("{0}%", query);
            string textQuery = String.Format("%{0}%", query);

            DetachedCriteria criteria = DetachedCriteria.For<Watershed>();
            criteria.Add(Expression.Or(
                Expression.Like("Name", textQuery),
                Expression.Like("DrainageCode", idQuery)
            ));
            Watershed[] results = Watershed.SlicedFindAll(start, limit, criteria,
                Order.Asc("Name"));

            criteria = DetachedCriteria.For<Watershed>();
            criteria.Add(Expression.Or(
                Expression.Like("Name", textQuery),
                Expression.Like("DrainageCode", idQuery)
            ));
            int count = new ScalarProjectionQuery<Watershed, int>(
                NHibernate.Expression.Projections.RowCount(),
                criteria
            ).Execute();

            Context.Response.ContentType = "text/javascript";
            RenderText(String.Format("{{ results: {0}, watersheds: {1} }}", count,
                JavaScriptConvert.SerializeObject(results)));
        }
		public void ScalarProjectionQueryTest()
		{
			Blog blog = new Blog();
			blog.Name = "hammett's blog";
			blog.Author = "hamilton verissimo";
			blog.Save();

			ScalarProjectionQuery<Blog, int> proj = new ScalarProjectionQuery<Blog, int>(Projections.RowCount());
			int rowCount = proj.Execute();
			Assert.AreEqual(1, rowCount);
		}
Пример #4
0
        public void AutoComplete(string query, int start, int limit)
        {
            Logger.Debug(String.Format("XHR call to AquaticSite Autocomplete for {0} received", query));
            string nameQuery = String.Format("%{0}%", query);

            AquaticSite[] aquaticSites = AquaticSite.SlicedFindAll(
                start,
                limit,
                CreateAutoCompleteCriteria(nameQuery),
                Order.Asc("AquaticSiteName")
            );

            int count = new ScalarProjectionQuery<AquaticSite, int>(
                Projections.RowCount(),
                CreateAutoCompleteCriteria(nameQuery)
            ).Execute();

            Context.Response.ContentType = "text/javascript";
            RenderText(String.Format("{{ results: {0}, aquaticSites: {1} }}", count,
                JavaScriptConvert.SerializeObject(aquaticSites)));
        }
        public void ScalarProjectionQueryTest()
        {
            Blog blog = new Blog();
            blog.Name = "hammett's blog";
            blog.Author = "hamilton verissimo";
            blog.Save();

            ScalarProjectionQuery<Blog, int> proj = new ScalarProjectionQuery<Blog, int>(Projections.RowCount());
            int rowCount = proj.Execute();
            Assert.AreEqual(1, rowCount);
        }