LINQ error: “<object> has no parameterless constructor.”

后端 未结 2 646
一生所求
一生所求 2021-01-22 01:31

I have a class method GetMS() as defined below, but when the method is called I get an error stating \'SLRD\' has no parameterless constructor. I don\'

2条回答
  •  误落风尘
    2021-01-22 01:54

    I don't understand why a parameterless constructor is even being called.

    My guess is that you are populating ChildRequests lazily via a Linq/EF query, so the objects are not created until you iterate over them (which is done as part of the First method). At that point, EF tries to create an instance using a parameterless constructor which does not exist.

提交回复
热议问题