0

After generation of DataContext class from my DB I've got CMCoreDataClassesDataContext class.

For unit-testing purpose I would like this class to be implementing my special interface, ICMCoreDataClassesDataContext. I could change designer.cs class but it will need to be updated each time when regenerated.

Is there any solution that allows to mark auto-generated class as to be inherited from my interface? I see possibility to change base class, but how can I specify 'base' interface?

P.S. Is it an option to create a base class that will be inherited from System.Data.Linq.DataContext AND my interface (ICMCoreDataClassesDataContext) and specify it as a base class for autogenerated one? It doesn't work due to necessity to declare required methods as abstract in base class (that is OK) and mark them with "override" in generated.

P.S. .NET 3.5, Linq2sql

1 Answer 1

3

The generated datacontext is a partial class. You can add a separate .cs file with the following:

public partial class MyDataContext : IMyInterface
{} 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.