Пример #1
0
        public static T[] FindAllForGrid(ref string hql, List <object> pars, int start, int limit, string sort, string dir, string[][] filters, bool startAnd)
        {
            hql += ActiveRecordHelp.GetFilterHql(sort, dir, filters, pars, startAnd);
            IList list = null;

            list = ExecuteQuery(new HqlPageQuery(hql, start, limit, pars.ToArray())) as IList;
            T[] result = new T[list.Count];
            list.CopyTo(result, 0);
            return(result);
        }
Пример #2
0
        public object Execute(ISession session)
        {
            //try
            //{
            IDbCommand cmd = session.Connection.CreateCommand();

            cmd.CommandText = ActiveRecordHelp.GetFilgerCount(cmd, _start, _limit, _sort, _dir, _tableName, _primaryKey, _filters, _otherWhere, _otherParameter);
            return(cmd.ExecuteScalar());
            //}
            //catch (Exception ex)
            //{ return 0; }
        }
Пример #3
0
        public object Execute(ISession session)
        {
            IDbCommand cmd = session.Connection.CreateCommand();

            cmd.CommandText = ActiveRecordHelp.GetFilterSql(_query, cmd, _start, _limit, _sort, _dir, _tableName, _primaryKey, _filters, _otherWhere, _otherParameter);
            List <T> list = new List <T>();
            //try
            //{
            IDataReader r = cmd.ExecuteReader();

            while (r.Read())
            {
                T o = new T();
                for (int i = 0; i < r.FieldCount; i++)
                {
                    object       value = r.GetValue(i);
                    PropertyInfo pro   = typeof(T).GetProperty(r.GetName(i));
                    if (pro != null)
                    {
                        if (pro.PropertyType == typeof(string) && value == DBNull.Value)
                        {
                            value = "";
                        }
                        if (pro.PropertyType == typeof(int) && value == DBNull.Value)
                        {
                            value = 0;
                        }
                        if (value == DBNull.Value)
                        {
                            value = null;
                        }
                        pro.SetValue(o, value, null);
                    }
                }
                list.Add(o);
            }
            //}
            //catch (Exception ex) { }
            return(list.ToArray());
        }