开发者

LINQ to SQL object to implement an interface?

In my database, I have the following tables

CustomExpressions
GlobalExpressions

I had corresponding POCO classes in my application

public class CustomExpressions: IExpression
{
    //blah blah blah
}

public class GlobalExpressions: IExpression
{
    //blah blah blah
}

and I have the inteface IExpression

interface IExpression
{
    //yada yada yada
}

One of my business objects in my application aggregates an object of type IExpression like the following

public class MyBusinessObject
{
    public IExpression { get; set; }
}

this is done because this property on the MyBusinessObject can either be of type CustomExpres开发者_StackOverflow中文版sion, or GlobalExpression, but is decided at dynamically.

This all worked fine, but I was directed to take out the CustomExpression and GlobalExpression object and to directly use the CustomExpression and GlobalExpression linqtosql object. This allows me to not have to convert from POCO to linqtosql object every time I need to do something with the database.

The problem with this tho, is that I no longer have CustomExpression and GlobalExpression objects that implement the IExpression interface.

What am I supposed to do in this situation? Is there a way to represent this relationship with that interface with these objects?


The classes are created as partial classes, you can simply add:

public partial class CustomExpressions: IExpression
{
        //blah blah blah
}

public partial class GlobalExpressions: IExpression
{
     //blah blah blah
}

and add the missing bits in there.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜