Eduardo Moreira
Eduardo Moreira

Reputation: 41

Only parameterless constructors and initializers are supported in LINQ to Entities

parcelas = (from docuRec in Dados.DOCUREC
                        where docuRec.CODALUNO == codAluno && docuRec.CODESCOLA == codEscola &&
                            (configBoleto.DtVencimentoInicial >= (docuRec.VENCESP != null ?
                            new DateTime(docuRec.DTVENCIMENTO.Year, docuRec.DTVENCIMENTO.Month, docuRec.VENCESP.Value) :
                                docuRec.DTVENCIMENTO))
                        select docuRec);

Only parameterless constructors and initializers are supported in LINQ to Entities

Can anybody help me?

Upvotes: 4

Views: 4261

Answers (1)

Bruno Brant
Bruno Brant

Reputation: 8564

In L2E you must have all your entities defining at least one parameterless constructor. That's necessary because the serializer must create an instance of your object and it doesn't know what parameters to pass;

The serializer then sets each property individually.

My guess is that Dados.DOCUREC doesn't define such a constructor.

Upvotes: 3

Related Questions