コード例 #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)));
        }
コード例 #2
0
        public void Update(object obj, string wheresql)
        {
            string iswhere = " where ";

            if (string.IsNullOrEmpty(wheresql))
            {
                iswhere = "";
            }
            string sql = DTUtilis.GetUpdateSql(TableName, obj) + iswhere + wheresql;

            Mysql.Instance.ExecuteSql(sql);
        }
コード例 #3
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));
        }
コード例 #4
0
        public void Add(object obj)
        {
            string sql = DTUtilis.GetInsertSql(TableName, obj);

            Mysql.Instance.ExecuteSql(sql);
        }