Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List in list (Model) Factory

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();
like image 983
Rafał Developer Avatar asked Nov 13 '22 20:11

Rafał Developer


1 Answers

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();
like image 99
Rafał Developer Avatar answered Nov 15 '22 08:11

Rafał Developer