Raf*_*per 5 c# nhibernate asp.net-mvc-3
我想在数据列表中创建数据列表.我相信这很难解释,但我会尽力解释我的问题.我创建了数据列表,但在此列表中,一些参数也是数据列表.我必须使用此代码编写,因为这是限制(我们的工厂).如果我获取的数据不是数据列表,那么一切正常.哪里有问题?如果我在列表中写列表,我会收到错误.也许你可以看到我的错误.
程序是编译的.
问题(我使用NHibernate中的映射从第三个表中获取数据):
DestynationName = (List<dictionaryNewInfoSupportList>x.DictImportantInformationSDestination.Select(n=> new DictionaryNewInfoSupportList { Id = n.Destination.Id, Name = n.Destination.Desciption}).ToList();
Run Code Online (Sandbox Code Playgroud)
模型中的DestynationName
public Ilist<dictionaryNewInfoSupportList> DestynationName;
Run Code Online (Sandbox Code Playgroud)
类:
class dictionaryNewInfoSupportList
{
public string Name {get; set;}
public int Id {get; set;}
}
Run Code Online (Sandbox Code Playgroud)
重要:
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;
}
Run Code Online (Sandbox Code Playgroud)
我有答案(主题已关闭)
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();
Run Code Online (Sandbox Code Playgroud)
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();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
598 次 |
| 最近记录: |