0

这是我第一次遇到这个错误。有人能帮我吗?

        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 list = (from f in context.APPLICANTs
                        select f.APPLICANT_ID).ToList();
            var applicantList = (from a in context.Profiles
                                 join app in context.APPLICANTs on a.PROFILE_ID equals app.Profile_id
                                 where list.Contains(app.APPLICANT_ID)
                                 select new APPLICANT());

            applicantdata = applicantList.Where(v => v.APPLICANT_LastName != null && v.APPLICANT_LastName != "" ).OrderBy(v => v.APPLICANT_ID).ToList();

            if (applicantdata.Any())
            {
                Cache.Set("applicants", applicantdata, 30);
            }
        }

我在这行有错误

 applicantdata = applicantList.Where(v => v.APPLICANT_LastName != null && v.APPLICANT_LastName != "" ).OrderBy(v => v.APPLICANT_ID).ToList();

谢谢,如果有人会帮助

4

1 回答 1

0

改变

var applicantList = (from a in context.Profiles
     join app in context.APPLICANTs on a.PROFILE_ID equals app.Profile_id
     where list.Contains(app.APPLICANT_ID)
     select new APPLICANT());

var applicantList = (from a in context.Profiles
       join app in context.APPLICANTs on a.PROFILE_ID equals app.Profile_id
       where list.Contains(app.APPLICANT_ID)
       select app);

如果您创建new APPLICANT()了新创建的申请人,但没有任何数据

并且applicantList.Where(v => v.APPLICANT_LastName != null && v.APPLICANT_LastName != "" )

可以改为

applicantList.Where(v => !String.IsNullOrEmpty(v.APPLICANT_LastName))
于 2013-05-09T03:55:15.253 回答