2012-10-18 25 views
5

Veri listesinden veri listesi oluşturmak istiyorum. Bunun açıklanması zor olabileceğine inanıyorum ama sorunumu çok açık bir şekilde açıklamaya çalışacağım. Veri listesi oluşturdum ancak bu listede bazı argümanlar da veri listesi. Bu kodu kullanarak yazmak zorundayım çünkü bu kısıtlama (Fabrikamız). Veri listesi olmayan veri alırsam, her şey doğru çalışıyor. Problem nerede? Listede bir liste yazarsam hata alıyorum. Belki orada benim hatamı görebilirsiniz.List in List (Model) Fabrika

Program derlenmiştir.

class dictionaryNewInfoSupportList 
{ 
public string Name {get; set;} 
public int Id {get; set;} 
} 

Önemli:

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; 

} 

public Ilist<dictionaryNewInfoSupportList> DestynationName; 

Sınıf Modeli

DestynationName = (List<dictionaryNewInfoSupportList>x.DictImportantInformationSDestination.Select(n=> new DictionaryNewInfoSupportList { Id = n.Destination.Id, Name = n.Destination.Desciption}).ToList(); 

DestynationName:

Sorun (NHibernate içinde eşleme kullanarak üçüncü bir tablodan veri almak)

Cevabın var (Konu Kapalı)

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(); 
+4

istenen prosedür @dove takip ediniz konuyu – dove

+0

kapatmak için en iyi yol cevap olarak bu koymak ve bunu kabul edin. Bu soru hala cevapsız görünüyor - ama sen kendin cevapladın (ki bu iyi). Bu yüzden "Kendi Sorunuzu Cevapla" yı tıklayın, yanıt olarak ekleyin ve iki gün içinde (bence) yanıt olarak kabul edip listeden çıkartabileceksiniz. –

cevap

1
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();