I would like to create list of data in list of data. I believe this can be difficult to explain but I will try explain my problem very clear. I created list of data but in this list some arguments are also list of data. I have to write using this code because this are restriction (Our Factory). If I take data, which are not list of data, everything working correct. Where is problem? If I write list in list I get error. Perhaps you can see there my mistake.
Program is compile.
Problem(I take data from third table using mapping in NHibernate):
DestynationName = (List<dictionaryNewInfoSupportList>x.DictImportantInformationSDestination.Select(n=> new DictionaryNewInfoSupportList { Id = n.Destination.Id, Name = n.Destination.Desciption}).ToList();
DestynationName in Model
public Ilist<dictionaryNewInfoSupportList> DestynationName;
Class:
class dictionaryNewInfoSupportList
{
public string Name {get; set;}
public int Id {get; set;}
}
Important:
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;
}
I have got answer (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();
                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();
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With