Only parameterless constructors and initializers are supported in LINQ to Entities

后端 未结 14 1358
暗喜
暗喜 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 16:05

    yeh, try it like this....

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

    this will new up your Payment object using a parameterless constructor, and then initialize the properties that are listed inside the curly braces { }

提交回复
热议问题