Only parameterless constructors and initializers are supported in LINQ to Entities

后端 未结 14 1379
暗喜
暗喜 2020-11-27 15:27

I have this error in this linq expression :

var naleznosci = (from nalTmp in db.Naleznosci
                              where nalTmp.idDziecko == idDziec
           


        
14条回答
  •  再見小時候
    2020-11-27 15:57

    without more info on 'Payments' this doesn't help much, but assuming you want to create a Payments object and set some of its properties based on column values:

    var naleznosci = (from nalTmp in db.Naleznosci
                                  where nalTmp.idDziecko == idDziec
                                  select new Payments
                                  {
                                      Imie = nalTmp.Dziecko.Imie,
                                      Nazwisko = nalTmp.Dziecko.Nazwisko,
                                      Nazwa= nalTmp.Miesiace.Nazwa,
                                      Kwota = nalTmp.Kwota,
                                      NazwaRodzajuOplaty = nalTmp.RodzajeOplat.NazwaRodzajuOplaty,
                                      NazwaTypuOplaty = nalTmp.RodzajeOplat.TypyOplat.NazwaTypuOplaty,
                                      DataRozliczenia = nalTmp.DataRozliczenia,
                                      TerminPlatnosci = nalTmp.TerminPlatnosci,
                                  }).ToList();
    

提交回复
热议问题