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());

mvc ef LINQ to Entities 不识别方法“Int32 Parse(System.String)”,因此该方法无法转换为存储表达式。的更多相关文章

  1. 报错: LINQ to Entities 不识别方法“Int32 Parse(System.String)

    断点调试发现报错的语句为: public ActionResult SomeMethod(string someId) { var temp = SomeService.LoadEntities(a ...

  2. LINQ to Entities 不识别方法“Int32 ToInt32(System.String)”,因此该方法无法转换为存储表达式。

      通常原始代码如下: Where id=Convert.ToInt32(cousid) 更改后代码: Var currentid= Convert.ToInt32(cousid); Wehre id ...

  3. Linq中字段数据类型转换问题(Linq to entity,LINQ to Entities 不识别方法"System.String ToString()"问题解决)

    1.在工作中碰到这样一个问题: 使用linq时,需要查询两个表,在这两张表中关联字段分别是int,和varchar()也就是string,在linq中对这两个字段进行关联, 如果强制类型转换两个不同类 ...

  4. LINQ to Entities不识别方法***,因此该方法无法转换为存储表达式

    我的程序里有这么一段代码: order.OrderExpressInfo = (from oei in orderExpressRepository.Entities where oei.OrderI ...

  5. LINQ to Entities 不识别方法“System.String ToString()”,因此该方法无法转换为存储表达式。

    var data = DataSource.Skip(iDisplayStart).Take(iDisplayLength).Select(o => new { MatNR = o.MatNR, ...

  6. Linq to Entities不识别方法

    db.UserValidates.Include(a => a.User).Where(uv => u.UserValidates.Contains(uv, c)).ToList(); 执 ...

  7. LINQ to Entities 不识别方法“System.DateTime AddDays(Double)

    今天本想在linq里按照时间筛选一下超时的数据,一共两个字段FeedBackTime(计划反馈时间).EndTime(实际反馈时间).需求是这样的,查找数据库里所有EndTime大于FeedBackT ...

  8. LINQ to Entities 不识别方法“System.String get_Item(Int32)”,因此该方法无法转换为存储表达式。

    1.LINQ to Entities 不识别方法“System.String get_Item(Int32)”,因此该方法无法转换为存储表达式.项目中发现linq to entities 不识别? , ...

  9. LINQ to Entities 不识别方法“System.Guid Parse(System.String)”,因此该方法无法转换为存储表达式。

    LINQ to Entities 不识别方法"System.Guid Parse(System.String)",因此该方法无法转换为存储表达式. linq 中不能转换类型

随机推荐

  1. gdbsever 使用说明

    gdbsever 使用说明 在新塘N3292x平台下 编译 gdbsever ./configure --target=arm-linux --host=arm-linux arm-linux-gdb ...

  2. 【转】Java读取matlab的.mat数据文件

    参考:Java读取mat文件 下载链接:ujmp  jmatio 下载完两个.jar文件之后,如何引用到java项目当中?项目名称->右键->Property->Java Build ...

  3. How to install OpenBazaar Server in CentOS7

    helps from: https://github.com/OpenBazaar/OpenBazaar-Server http://stackoverflow.com/questions/24917 ...

  4. 自定义el函数

    1.1.1 自定义EL函数(EL调用Java的函数) 第一步:创建一个Java类.方法必须是静态方法. public static String sayHello(String name){ retu ...

  5. Firefox下载自动保存

    profile.setPreference("browser.download.folderList", 2); profile.setPreference("brows ...

  6. java 数组中插入新的元素

    class Demo1 { public static void main(String[] args) { /* 5. 有如下歌曲数组 String[] musics = new String[]{ ...

  7. iOS 获取键盘view 覆盖新view

    UIWindow *window = [[[UIApplication sharedApplication] windows] lastObject];    UIView * keyview=[[w ...

  8. tomcat 配置项目指定域名

    <Host name="www.xxx.com" appBase="D:/tomcat/webapps/web"> <alias>xxx ...

  9. TextSwitcher 简单用例

    TextSwitcher 字面理解是文字交换器,是ViewSwitcher的子类,从ViewSwitcher来看,是View交换器,TextSwitcher继承自ViewSwitcher,显然是交换T ...

  10. html学习第一天笔记——第七章节

    第7章 CSS样式基本知识<span style="color:blue"> </span>嵌入式css样式,写在当前的文件中[**********]嵌入式 ...