예제 #1
0
        public static void Initialize(MySqlConnection conn)
        {
            tableInfo   = MySqlDapper.ParseTable(typeof(T));
            sqlToInsert = MySqlDapper.GetSqlToInsert(tableInfo);
            sqlToUpsert = MySqlDapper.GetSqlToUpsert(tableInfo);

            string sqlToCreate = MySqlDapper.GetSqlToCreate(tableInfo);

            conn.Execute(sqlToCreate);
        }
예제 #2
0
        public static async Task <PageData <T> > QueryPageAsync(int page, int size, string where = null, string orderBy = null)
        {
            using (var conn = new MySqlConnection(ConnectionString4Slave))
            {
                string sql1     = MySqlDapper.GetSqlToQueryTotalRow(tableInfo, where);
                int    totalRow = await conn.ExecuteScalarAsync <int>(sql1);

                int totalPage = (int)Math.Floor((decimal)(totalRow + size - 1) / size);
                int offset    = page * size;

                string sql2 = MySqlDapper.GetSqlToQueryPage(tableInfo, offset, size, where, orderBy);
                var    list = await MySqlDapper.QueryAsync <T>(ConnectionString4Slave, sql2);

                return(new PageData <T>()
                {
                    TotalRow = totalRow,
                    TotalPage = totalPage,
                    List = list
                });
            }
        }
예제 #3
0
        public static List <T> Query(string where = null, string orderBy = null)
        {
            string sql = MySqlDapper.GetSqlToQuery(tableInfo, where, orderBy);

            return(MySqlDapper.Query <T>(ConnectionString4Slave, sql));
        }
예제 #4
0
        public static async Task <List <T> > QueryAsync(string where = null, string orderBy = null)
        {
            string sql = MySqlDapper.GetSqlToQuery(tableInfo, where, orderBy);

            return(await MySqlDapper.QueryAsync <T>(ConnectionString4Slave, sql));
        }
예제 #5
0
 public TestController(MySqlDapper dapper)
 {
     _dapper = dapper;
 }