示例#1
0
文件: Db.cs 项目: IGionny/Molto
        public int Update <T>(T item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            var sql = _sqlQueryBuilder.UpdateSql <T>();
            //Get all the properties value except for the primary key
            var values = _sqlQueryBuilder.GetColumnsValue <T>(item).Where(x => !x.Key.IsPrimaryKey).Select(x => x.Value)
                         .ToList();

            values.Add(_sqlQueryBuilder.GetPrimaryKeyValue(item));
            return(Execute(sql, values.ToArray()));
        }