C# 无法将类型“syste.collections.generics.list”隐式转换为“system.collections.generics.list”
我得到一个错误: 无法将类型System.Collections.Generics.List隐式转换为System.Collections.Generics.List 这是数据库连接问题吗? 这是数据库连接错误吗? MeritMAster_QuestionPeparsettings和MeritMAster.data.MeritMAster_QuestionPeparsettings是编译器的两种不同类型,这两种类型之间不存在转换C# 无法将类型“syste.collections.generics.list”隐式转换为“system.collections.generics.list”,c#,asp.net,asp.net-mvc,entity-framework,C#,Asp.net,Asp.net Mvc,Entity Framework,我得到一个错误: 无法将类型System.Collections.Generics.List隐式转换为System.Collections.Generics.List 这是数据库连接问题吗? 这是数据库连接错误吗? MeritMAster_QuestionPeparsettings和MeritMAster.data.MeritMAster_QuestionPeparsettings是编译器的两种不同类型,这两种类型之间不存在转换 您需要定义隐式或显式转换,或者手动转换它们。您可以使用各种技术,例
您需要定义隐式或显式转换,或者手动转换它们。您可以使用各种技术,例如使用IQueryable.ForAll或IEnumerable。选择扩展方法。sorry@Yuval。我找不到你。你能再多给我一点描述或代码来解决我的错误吗。请帮助我如何转换您能否显示MeritMAster_QuestionPaperSettings类和MeritMAster.data.MeritMAster_QuestionPeparSetting类或显示它们之间的关系。
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
}
}
}