【发布时间】:2013-05-14 18:45:00
【问题描述】:
现在我正在尝试右加入一个异常弹出。
这是我的控制器
public IEnumerable<APPLICANT> GetApplicant()
{
IEnumerable<APPLICANT> applicantdata = Cache.Get("applicants") as IEnumerable<APPLICANT>;
IEnumerable<Profile> profiledata = Cache.Get("profiles") as IEnumerable<Profile>;
if (applicantdata == null)
{
var applicantList = (from a in context.Profiles
join app in context.APPLICANTs
on a.PROFILE_ID equals app.Profile_id into joined
from j in joined.DefaultIfEmpty()
select new
{
APPLICANT = j,
Profile = a,
}).Take(1000).AsEnumerable();
applicantdata = applicantList.AsEnumerable().ToList();
if (applicantdata.Any())
{
Cache.Set("applicants", applicantdata, 30);
}
}
return applicantdata;
}
这是错误
applicantdata = applicantList.AsEnumerable().ToList();
无法将类型“System.Collections.Generic.List
”隐式转换为 'System.Collections.Generic.IEnumerable '。显式 存在转换(您是否缺少演员表?)
【问题讨论】:
-
你如何定义
APPLICANT? -
如果您使用
IEnumerable<Applicant>作为返回类型,那么为什么要在LINQ 中创建匿名类型?您需要使用select new Applicant{ }
标签: c# asp.net asp.net-mvc linq entity-framework