我收到错误:
无法隐式将
System.Collections.Generics.List<MeritMaste_QuestionPeparsettings>
类型转换为System.Collections.Generics.List<MeritMaste.data.MeritMAster_QuestionPeparSettng>
public class DataManager
{
public static void OnlineExamLists(
out List<MeritMaste_QuestionPaperSettings> examQuestionSettings,
out List<MeritMaster_QuestionBank> questionBanks, string examCode)
{
using (var dbcontext = new meritmasterEntities())
{
// var exam_code = dbcontext.MeritMaste_QuestionPaperSettings.Where(m => m.ID == examCode).FirstOrDefault().ex_code;
//(from k in dbcontext.MeritMaste_QuestionPaperSettings where k.Status == true && k.ID == examCode select k.ex_code).ToList();
examQuestionSettings = (from k in dbcontext.MeritMaste_QuestionPaperSettings
where k.Status == true && k.ex_code == examCode
select k).ToList();
var examsettingslocal = examQuestionSettings.FirstOrDefault();
var kabqu = new List<MeritMaster_QuestionBank>();
var queBank = examsettingslocal == null
? kabqu
: (from k in dbcontext.MeritMaster_QuestionBank
where k.Status == true && k.Course_ID == examsettingslocal.CourseId
select k).ToList();
// questionBanks = queBank.ToList();
var questionbanklocal = dbcontext.MeritMaste_QuestionPaperSettings.ToList();
questionBanks = (from es in examQuestionSettings.ToList()
join qb in queBank.ToList() on new {p1 = (int) es.CourseId, p2 = (int) es.QuestionIds} equals
new {p1 = (int) qb.Course_ID, p2 = (int) qb.ID}
where es.ex_code == examCode && es.Status == true && qb.Status == true
select qb).ToList();
//join a in questionpaperlocal.ToList() on k.QuestionIds equals a.ID
//where k.Status == true && a.Status == true
////orderby a.Id ascending
//select k
}
}
}
答案 0 :(得分:0)
MeritMaste_QuestionPeparsettings
和MeritMaste.data.MeritMAster_QuestionPeparSettng
是编译器的两种不同类型,并且在这两种类型之间不存在转换。
您需要定义转换(隐式或显式),或手动转换它们。您可以使用各种技术执行此操作,例如使用IQueryable.ForAll
或IEnumerable.Select
扩展方法。