日期:2014-05-20  浏览次数:20711 次

LinqToSqlExtensions的update怎么使用
我看LinqToSqlExtensions多加了两个delete 和update
 public static class TableExtensions
    {
        public static int Delete<TEntity>(this Table<TEntity> table, Expression<Func<TEntity, bool>> predicate) where TEntity : class;
        public static int Update<TEntity>(this Table<TEntity> table, Expression<Func<TEntity, TEntity>> evaluator, Expression<Func<TEntity, bool>> predicate) where TEntity : class;
    }
像delete容易理解和使用
比如 db.table1.delete(k=>k.id>10)这样
但update就知道怎么用了,尝试几种都出错!哪位知道怎么使用
比如 想更新 
table1 
  id int,
  num int
 id大于10的num加1 像sql语句 update table1 set num=num+1 where id>10
------最佳解决方案--------------------
db.table1.Update(x => { x.num = x.num + 1; return x; }, x => x.id > 10);