Problem with interface implementation in partial classes

后端 未结 2 1251
北海茫月
北海茫月 2020-12-11 04:01

I have a question regarding a problem with L2S, Autogenerated DataContext and the use of Partial Classes. I have abstracted my datacontext and for every table I use, I\'m im

2条回答
  •  旧巷少年郎
    2020-12-11 04:52

    Return types aren't covariant in C#. As you can't change the auto-generated code the only solution I see is to change the interface:

    public interface Interface
    {
        T Instance { get; }
    }
    

    And change your partial class accordingly:

    public partial class Class : Interface { }
    

提交回复
热议问题