LINQ to SQL对象实现一个接口?
在我的数据库中,我有以下表格
CustomExpressions
GlobalExpressions
,我的应用程序中有相应的 POCO 类
public class CustomExpressions: IExpression
{
//blah blah blah
}
public class GlobalExpressions: IExpression
{
//blah blah blah
}
,并且我有接口 IExpression
interface IExpression
{
//yada yada yada
}
我的应用程序中的业务对象之一聚合了 IExpression 类型的对象,例如 之所以
public class MyBusinessObject
{
public IExpression { get; set; }
}
这样做,是因为 MyBusinessObject 上的此属性可以是 CustomExpression 或 GlobalExpression 类型,但是动态决定的。
这一切都工作正常,但我被指示取出 CustomExpression 和 GlobalExpression 对象并直接使用 CustomExpression 和 GlobalExpression linqtosql 对象。这使我不必每次需要对数据库执行某些操作时都从 POCO 转换为 linqtosql 对象。
但问题是我不再拥有实现 IExpression 接口的 CustomExpression 和 GlobalExpression 对象。
在这种情况下我该怎么办?有没有办法用这些对象来表示与该接口的这种关系?
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 CustomExpression, 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这些类被创建为部分类,您可以简单地添加:
并在其中添加缺少的位。
The classes are created as partial classes, you can simply add:
and add the missing bits in there.