예제 #1
0
        public string GetDeleteByIdSql <T>()
        {
            var table = MySqlCache.GetTableEntity <T>();

            CommonUtil.CheckTableKey(table);
            return(table.DeleteByIdSql);
        }
예제 #2
0
        public string GetInsertIdentitySql <T>()
        {
            var table = MySqlCache.GetTableEntity <T>();

            CommonUtil.CheckTableKey(table);
            return(table.InsertIdentitySql);
        }
예제 #3
0
        public string GetExistsKeySql <T>()
        {
            var table = MySqlCache.GetTableEntity <T>();

            CommonUtil.CheckTableKey(table);
            return(string.Format("SELECT COUNT(1) FROM `{0}` WHERE `{1}`=@{1}", table.TableName, table.KeyName));
        }
예제 #4
0
        public string GetBySkipTakeSql <T>(int skip, int take, string where, string returnFields, string orderBy)
        {
            var           table = MySqlCache.GetTableEntity <T>();
            StringBuilder sb    = new StringBuilder();

            InitPage(sb, table, skip, take, where, returnFields, orderBy);
            return(sb.ToString());
        }
예제 #5
0
        public string GetByWhereFirstSql <T>(string where, string returnFields)
        {
            var table = MySqlCache.GetTableEntity <T>();

            if (string.IsNullOrEmpty(returnFields))
            {
                returnFields = table.AllFields;
            }
            return(string.Format("SELECT {0} FROM `{1}` {2} LIMIT 1", returnFields, table.TableName, where));
        }
예제 #6
0
        public string GetByIdsWithFieldSql <T>(string field, string returnFields)
        {
            var table = MySqlCache.GetTableEntity <T>();

            if (string.IsNullOrEmpty(returnFields))
            {
                returnFields = table.AllFields;
            }
            return(string.Format("SELECT {0} FROM `{1}` WHERE `{2}` IN @ids", returnFields, table.TableName, field));
        }
예제 #7
0
        public string GetUpdateSql <T>(string updateFields)
        {
            var table = MySqlCache.GetTableEntity <T>();

            CommonUtil.CheckTableKey(table);
            if (string.IsNullOrEmpty(updateFields))
            {
                return(table.UpdateSql);
            }
            return(CommonUtil.CreateUpdateSql(table, updateFields, "`", "`"));
        }
예제 #8
0
        public string GetSchemaTableSql <T>(string returnFields)
        {
            var table = MySqlCache.GetTableEntity <T>();

            if (string.IsNullOrEmpty(returnFields))
            {
                return(string.Format("SELECT {0} FROM `{1}` LIMIT 0", table.AllFields, table.TableName));
            }
            else
            {
                return(string.Format("SELECT {0} FROM `{1}` LIMIT 0", returnFields, table.TableName));
            }
        }
예제 #9
0
        public string GetAllSql <T>(string returnFields, string orderBy)
        {
            var table = MySqlCache.GetTableEntity <T>();

            if (string.IsNullOrEmpty(returnFields))
            {
                return(table.GetAllSql + orderBy);
            }
            else
            {
                return(string.Format("SELECT {0} FROM `{1}` {2}", returnFields, table.TableName, orderBy));
            }
        }
예제 #10
0
        public string GetByIdsSql <T>(string returnFields)
        {
            var table = MySqlCache.GetTableEntity <T>();

            CommonUtil.CheckTableKey(table);
            if (string.IsNullOrEmpty(returnFields))
            {
                return(table.GetByIdsSql);
            }
            else
            {
                return(string.Format("SELECT {0} FROM `{1}` WHERE `{2}` IN @ids", returnFields, table.TableName, table.KeyName));
            }
        }
예제 #11
0
        public string GetPageSql <T>(int pageIndex, int pageSize, string where, string returnFields, string orderBy)
        {
            int skip = 0;

            if (pageIndex > 0)
            {
                skip = (pageIndex - 1) * pageSize;
            }
            var           table = MySqlCache.GetTableEntity <T>();
            StringBuilder sb    = new StringBuilder();

            sb.AppendFormat("SELECT COUNT(1) FROM `{0}` {1};", table.TableName, where);
            InitPage(sb, table, skip, pageSize, where, returnFields, orderBy);
            return(sb.ToString());
        }
예제 #12
0
        public string GetUpdateByWhereSql <T>(string where, string updateFields)
        {
            var table = MySqlCache.GetTableEntity <T>();

            return(CommonUtil.CreateUpdateByWhereSql(table, where, updateFields, "`", "`"));
        }
예제 #13
0
 public string GetInsertReturnIdSql <T>(string sequence = null)
 {
     return(MySqlCache.GetTableEntity <T>().InsertReturnIdSql);
 }
예제 #14
0
 public string GetInsertSql <T>()
 {
     return(MySqlCache.GetTableEntity <T>().InsertSql);
 }
예제 #15
0
        public string GetTotalSql <T>(string where)
        {
            var table = MySqlCache.GetTableEntity <T>();

            return(string.Format("SELECT COUNT(1) FROM `{0}` {1}", table.TableName, where));
        }
예제 #16
0
 public string GetDeleteAllSql <T>()
 {
     return(MySqlCache.GetTableEntity <T>().DeleteAllSql);
 }