示例#1
0
        public async Task <ActionResult> Get()
        {
            var command = new CommandSelectTables();
            await _dbCon.ExecuteAsync(command);

            if (command.IsSuccessful && command.Data.Length > 0)
            {
                Response.StatusCode = StatusCodes.Status200OK;
                return(Content(command.Data, "application/json"));
            }

            return(NoContent());
        }
示例#2
0
        public async Task <ActionResult> Publish(string name)
        {
            var command = new CommandPublishTable(name);
            await _dbCon.ExecuteAsync(command);

            if (command.IsSuccessful)
            {
                return(Created($"api/Table/{name}Publish", command.Data));
            }

            return(NotFound(command.Error));
        }
示例#3
0
        public async Task <ActionResult> Get(
            string name,
            [FromQuery(Name = "$page")] int page,
            [FromQuery(Name = "$size")] int size,
            [FromQuery(Name = "$select")] string select,
            [FromQuery(Name = "$order")] string order,
            [FromQuery(Name = "$filter")] string filter)
        {
            var command = new CommandCustomSqlQuery(name, select, order, filter, page, size);
            await _dbCon.ExecuteAsync(command);

            if (!command.IsSuccessful)
            {
                return(NotFound());
            }

            Response.StatusCode = StatusCodes.Status200OK;
            return(Content(command.Data, "application/json"));
        }
示例#4
0
        public async Task <int> InsertAsync(T entity)
        {
            SqlProvider.FormatInsert(entity);

            return(await DbCon.ExecuteAsync(SqlProvider.SqlString, SqlProvider.Params, DbTransaction));
        }
示例#5
0
        public async Task <int> DeleteAsync()
        {
            SqlProvider.FormatDelete();

            return(await DbCon.ExecuteAsync(SqlProvider.SqlString, SqlProvider.Params, DbTransaction));
        }
示例#6
0
        public async Task <int> UpdateAsync(Expression <Func <T, T> > updateExpression)
        {
            SqlProvider.FormatUpdate(updateExpression);

            return(await DbCon.ExecuteAsync(SqlProvider.SqlString, SqlProvider.Params, DbTransaction));
        }