Ejemplo n.º 1
0
        public T GetEntity <T>(string wheresql)
        {
            if (string.IsNullOrEmpty(wheresql))
            {
                throw new Exception();
            }
            Type   type = typeof(T);
            object o    = Activator.CreateInstance(type);
            string sql  = "select * from " + TableName + " where " + wheresql + " limit 1";

            return((T)(DTUtilis.LoadValueFromDT(Mysql.Instance.Query(sql).Tables["ds"], o)));
        }
Ejemplo n.º 2
0
        public List <T> GetList <T>(string wheresql, string orderbysql)
        {
            string iswhere = " where ";

            if (string.IsNullOrEmpty(wheresql))
            {
                iswhere = "";
            }
            string isorderby = " order by ";

            if (string.IsNullOrEmpty(orderbysql))
            {
                isorderby = "";
            }
            List <T> temps = new List <T>();
            string   sql   = "SELECT * FROM " + TableName + iswhere + wheresql + isorderby + orderbysql;

            return(DTUtilis.LoadValueFromDT <T>(Mysql.Instance.Query(sql).Tables["ds"], temps));
        }