Tôi muốn tạo danh sách dữ liệu trong danh sách dữ liệu. Tôi tin rằng điều này có thể khó giải thích nhưng tôi sẽ cố gắng giải thích vấn đề của tôi rất rõ ràng. Tôi đã tạo danh sách dữ liệu nhưng trong danh sách này, một số đối số cũng là danh sách dữ liệu. Tôi phải viết bằng cách sử dụng mã này bởi vì đây là hạn chế (Nhà máy của chúng tôi). Nếu tôi lấy dữ liệu, đó không phải là danh sách dữ liệu, mọi thứ đều hoạt động chính xác. Vấn đề ở đâu? Nếu tôi viết danh sách trong danh sách tôi gặp lỗi. Có lẽ bạn có thể thấy có lỗi của tôi.Danh sách trong danh sách (Kiểu) Nhà máy
Chương trình được biên dịch.
Vấn đề (tôi lấy dữ liệu từ bảng thứ ba sử dụng bản đồ trong NHibernate):
DestynationName = (List<dictionaryNewInfoSupportList>x.DictImportantInformationSDestination.Select(n=> new DictionaryNewInfoSupportList { Id = n.Destination.Id, Name = n.Destination.Desciption}).ToList();
DestynationName trong Model
public Ilist<dictionaryNewInfoSupportList> DestynationName;
Class:
class dictionaryNewInfoSupportList
{
public string Name {get; set;}
public int Id {get; set;}
}
Chú ý:
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;
}
tôi đã có câu trả lời (Topic Closed)
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();
đặt này là câu trả lời và chấp nhận nó, cách tốt nhất để đóng chủ đề – dove
Hãy làm theo các @dove thủ tục yêu cầu. Câu hỏi này vẫn hiển thị là chưa được trả lời - nhưng bạn đã tự trả lời câu hỏi đó (điều đó là tốt). Vì vậy, hãy nhấp vào "Trả lời câu hỏi của riêng bạn", thêm nó như là một câu trả lời, và trong hai ngày (tôi nghĩ) bạn sẽ có thể chấp nhận nó như là câu trả lời và nhận được nó ra khỏi danh sách. –