Ejemplo n.º 1
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; }
        }
Ejemplo n.º 2
0
        public object Execute(ISession session)
        {
            CommonDictionary dic   = ActiveRecordHelp.GetFilgerCount(_tableName, _filters, _otherWhere, _otherParameter);
            ISQLQuery        query = session.CreateSQLQuery(dic.ContentSql);

            if (dic.Parameters != null)
            {
                foreach (DictionaryEntry par in dic.Parameters)
                {
                    query.SetParameter(par.Key.ToString(), par.Value);
                }
            }

            return(query.List()[0]);
        }
Ejemplo n.º 3
0
        public object Execute(ISession session)
        {
            CommonDictionary dic   = ActiveRecordHelp.GetFilterSql(_query, _start, _limit, _sort, _dir, _tableName, _primaryKey, _filters, _otherWhere, _otherParameter);
            ISQLQuery        query = session.CreateSQLQuery(dic.ContentSql).AddEntity(typeof(T));

            if (dic.Parameters != null)
            {
                foreach (DictionaryEntry par in dic.Parameters)
                {
                    query.SetParameter(par.Key.ToString(), par.Value);
                }
            }

            return(query.List());
        }
Ejemplo n.º 4
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 = null;
                            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) { throw ex; }
            return(list.ToArray());
        }