예제 #1
0
        public async Task <int> UpdateStock(Models.Stock stock)
        {
            var getById = new Condition("id", Convert.ToString(stock.Id), BinaryOperators.Equal);
            Dictionary <LogicOperators, Condition> condition = new Dictionary <LogicOperators, Condition> {
                { LogicOperators.FirstCondition, getById }
            };
            var query   = new UpdateQuery(Tables.StockTable, Tables.StockFields.Where(x => x != "ID").ToList(), stock.GetFieldValues(false), condition);
            var command = new SqlCommand(query.ToString(), _connection);

            return(await command.ExecuteNonQueryAsync());
        }
예제 #2
0
        public async Task <int> Update <T>(T element, string tableName, List <string> fields)
        {
            var model   = (IBaseModel)element;
            var getById = new Condition("id", Convert.ToString(model.Id), BinaryOperators.Equal);
            Dictionary <LogicOperators, Condition> condition = new Dictionary <LogicOperators, Condition> {
                { LogicOperators.FirstCondition, getById }
            };
            var query   = new UpdateQuery(tableName, fields.Where(x => x != "ID").ToList(), model.GetFieldValues(false), condition);
            var command = new SqlCommand(query.ToString(), _connection);

            return(await command.ExecuteNonQueryAsync());
        }