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

后端 未结 2 621
一生所求
一生所求 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 02:16

    The error you get is pretty clear. You missed to define a parameterless constructor.

    public class SLR : BaseEntity
    {
        public SLR() : base
        {
        }
    
        // ...
        public virtual ICollection ChildRequests { get; set; }
    }
    

    The reason this is happens is the fact that your base class may have a parameterless constructor. So you have to define one for the derived class, SLR.

提交回复
热议问题