Пример #1
0
        public object Execute(ISession session)
        {
            session.FlushMode = FlushMode.Never;
            session.CacheMode = CacheMode.Ignore;

            string cql    = string.Format("select count(*) {0}", _sql.Substring(_sql.LastIndexOf("from")));
            var    cquery = session.CreateSQLQuery(cql);
            var    count  = Convert.ToInt32(cquery.UniqueResult());

            ISQLQuery query = session.CreateSQLQuery(_sql).AddEntity(typeof(T));

            query.SetReadOnly(true);
            if (_paras != null)
            {
                for (int i = 0; i < _paras.Length; i++)
                {
                    query.SetParameter(i, _paras[i]);
                }
            }
            var results = new List <T>(count);

            query.List(results);
            return(results);
        }