Problem with interface implementation in partial classes.

Posted by Bas on Stack Overflow See other posts from Stack Overflow or by Bas
Published on 2010-04-09T09:58:22Z Indexed on 2010/04/09 10:03 UTC
Read the original article Hit count: 341

Filed under:
|
|
|

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 implementing a class with an interface. In the code below you can see I have the Interface and two partial classes. The first class is just there to make sure the class in the auto-generated datacontext inherets Interface. The other autogenerated class makes sure the method from Interface is implemented.

namespace PartialProject.objects
{

public interface Interface
{
    Interface Instance { get; }
}

//To make sure the autogenerated code inherits Interface
public partial class Class : Interface { }

//This is autogenerated
public partial class Class
{
    public Class Instance
    {
        get
        {
            return this.Instance;
        }
    }
}

}

Now my problem is that the method implemented in the autogenerated class gives the following error: -> Property 'Instance' cannot implement property from interface 'PartialProject.objects.Interface'. Type should be 'PartialProjects.objects.Interface'. <-

Any idea how this error can be resolved? Keep in mind that I can't edit anything in the autogenerated code.

Thanks in advance!

© Stack Overflow or respective owner

Related posts about linq-to-sql

Related posts about c#