private sys_User GetUserInfo()
{
sys_User model = null;
var userId = Convert.ToInt32(AccountHelper.GetAccountUserId());
var list = BLLSingleton.Instance.IUserService.GetListBy(c => c.UserId == userId);
if (list != null)
model = list.FirstOrDefault();
return model;
}
---------------------------------------------------------------------------------------
mvc ef 識別不了的(會報LINQ to Entities 不識別方法“Int32 ToInt32(System.String) 錯誤)
原因在於linq表達式中無法識別convert方法.
因為where里面不能調用這種convert等C#方法 要么在外面轉好了int類型添加進去
tostring等方法也不能放到where里面調用 因為他要解析lamda表達式 而不是去解析C#的方法
所以事前將string轉成int 在用
var userId = Convert.ToInt32(AccountHelper.GetAccountUserId());