开发者

Linq2sql: how to 'inherit' data context from custom interface?

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 desi开发者_StackOverflow社区gner.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


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

public partial class MyDataContext : IMyInterface
{} 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜