编译器错误请帮我 [英] compiler error help me please

查看:81
本文介绍了编译器错误请帮我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我
我的代码中出现此错误,我想在n层编程中使用实体框架:
错误1无法将类型``System.Linq.IQueryable< domain.model.tbl_personinfo>''隐式转换为``System.Collections.Generic.List< domain.model.tbl_personinfo>''.存在显式转换(您是否缺少演员表?)

这是我的代码:

please help me
i have this error in my code,i want to use entity framework in n-tier programming:
Error 1 Cannot implicitly convert type ''System.Linq.IQueryable<domain.model.tbl_personinfo>'' to ''System.Collections.Generic.List<domain.model.tbl_personinfo>''. An explicit conversion exists (are you missing a cast?)

this is my code:

List<tbl_personinfo> c = marsh.tbl_PersonInfo.Where(k => k.Name.Contains(ss)||k.Family.Contains(ss2));

推荐答案

在LINQ表达式的末尾添加对.ToList方法的调用.
Add a call to .ToList method at the end of LINQ expression.


尝试:
List c = marsh.tbl_PersonInfo.Where(k => k.Name.Contains(ss)
||k.Family.Contains(ss2)).ToList();



也可以尝试:



Also try :

List<yourobject> x =  marsh.tbl_PersonInfo.Where(delegate(yourobj k) { return k.Contains(ss); }).ToList();</yourobject>


这篇关于编译器错误请帮我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆