我有这些课程:
public class VwSelectBrochures
{
public List<SelectBrochure> SelectBrochures { get; set; }
}
public class SelectBrochure
{
public int BrochureId { get; set; }
public string UrlImage { get; set; }
public string Description { get; set; }
public string Cat1Description { get; set; }
public string Cat2Description { get; set; }
public string Cat3Description { get; set; }
public List<LangSelection> Languages { get; set; }
}
public class LangSelection
{
public int Id { get; set; }
public string Description { get; set; }
public bool Vink { get; set; }
}
这行代码:
var dbmodel2 =
from x in
brochures.AsEnumerable().Select(
x => new SelectBrochure {BrochureId = x.Id, Description = x.Description, UrlImage = x.UrlImage,
Languages = new List<LangSelection>(from y in x.BrochureLanguages select new LangSelection(){Description = y.Language.Description, Id = y.Language.Id})})
select x;
Brochures 和 BrochureLanguages 是我的数据库模型。
我知道我收到了错误,因为我无法执行“来自 x.BrochureLanguages 中的 y”,但我不知道如何解决这个问题。
我真正想要的是将所有小册子放入 VwSelectBrochures 类。