DefaultIfEmpty()
当我为我添加语句以右加入我的数据时,我的控制器出现异常。.
这是我的控制器:
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(new APPLICANT())
select new
{
APPLICANT = j,
Profile = a,
}).Take(1000).AsEnumerable();
applicantdata = applicantList.ToList();
if (applicantdata.Any())
{
Cache.Set("applicants", applicantdata, 30);
}
}
return applicantdata;
}
这是我得到异常的行:
applicantdata = applicantList.ToList();
这是例外
无法将类型“System.Collections.Generic.List”隐式转换为“System.Collections.Generic.IEnumerable”。存在显式转换(您是否缺少演员表?)