update 更新出现 值不能为 null 的错误 返回
我使用nuget 上的 sqlsugar最新版本,以下是执行语句
int i = db.Updateable(entity).UpdateColumns(expr).ExecuteCommand();
entity和expr都有值这个可以确定
实体对象格式如下:
public class Tb_AppToken
{
public int? ID { get; set; }
public string AppToken { get; set; }
public string AppName { get; set; }
public string AppDescripts { get; set; }
public DateTime? CreateDate { get; set; }
public int? State { get; set; }
public DateTime? ExpirDate { get; set; }
}
ID是主键
以下是错误信息:
值不能为 null。
参数名: source
[ArgumentNullException: 值不能为 null。
参数名: source]
System.Linq.Enumerable.Select(IEnumerable`1 source, Func`2 selector) +6087164
SqlSugar.UpdateableProvider`1.UpdateColumns(Expression`1 columns) +353
Kingsun.Framework.Manager.SqlSugarManager.Update(T entity, Expression`1 primarykey, Expression`1 expr) in
Kingspeak.AdminController.ApplicationController.ChangeState(Int32 ID, Int32 State) in
lambda_method(Closure , ControllerBase , Object[] ) +198
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +229
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +35
System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +39
热忱回答(2)
-
fate stay night VIP0
2017/12/28这个是EXP语法错了,参考文档,并且版本更新到最新
0 回复 -
绿芽 VIP0
2018/12/14记录一下,参数接收要使用以下类型
model 是 Expression<Func<T, T>> 类型。不能是 Expression<Func<T, object>> 类型。
dbClient.Updateable<T>().UpdateColumns(model).Where(expression).ExecuteCommand();
0 回复