我想在数据列表中创建数据列表。我相信这可能很难解释,但我会尝试非常清楚地解释我的问题。我创建了数据列表,但在此列表中,一些参数也是数据列表。我必须使用此代码编写,因为这是限制(我们的工厂)。如果我获取不是数据列表的数据,则一切正常。问题出在哪里?如果我在列表中写列表,我会得到错误。也许你可以看到我的错误。
程序正在编译。
问题(我使用 NHibernate 中的映射从第三个表中获取数据):
DestynationName = (List<dictionaryNewInfoSupportList>x.DictImportantInformationSDestination.Select(n=> new DictionaryNewInfoSupportList { Id = n.Destination.Id, Name = n.Destination.Desciption}).ToList();
模型中的目标名称
public Ilist<dictionaryNewInfoSupportList> DestynationName;
班级:
class dictionaryNewInfoSupportList
{
public string Name {get; set;}
public int Id {get; set;}
}
重要的:
public IEnumerable<DictionaryListModel> OnList(DictionayDisplayModel dictionary DisplayModel, int jtStartIndex = 0, int jtPageSize = 0, string jtSorting = null)
{
var displayModel = (DictionaryNewInfoDisplayModel)dictionaryDisplayModel;
if (displayModel == null)
var list = _dictImportantInformation.GetList().Select(
x=> new DictionaryNewInfoListModel
{
Id = x.Id
Description = x.Description,
IsActiveYN = x.IsActive,
DestynationName = (List<DictionaryNewInfoSupportList>) x.DictImportantInformationXDestination.Select(n => new DictionaryNewInfoSupportList
{ Id = n.Destination.Id, Name = Destination.Description}).To.List()
}
).ToList();
return list;
}
我有答案(话题已关闭)
var list = _dictImportantInformation.GetList().ToList().Select(
x => new DictionaryNewInfoListModel
{
Id = x.Id,
Description = x.Description,
IsActiveYN = x.IsActive,
DeestynationName = x.DictImportantInformationXDestination.Select(n => new DictionaryNewInfoSupportList
{ Id = n.Destination.Id, Name = n.Destination.Description }).ToList()
}
).ToList();