如何使用 Telerik OpenAccess 的接口
我正在尝试使用接口实现我的持久类。 我创建了以下
public interface IFoo
{
int Id {get;set;}
}
public class Foo : IFoo
{
private int _id;
public int Id {get{return _id;} set{_id = value;}}
}
public interface IBar
{
int Id {get;set;}
IFoo Foo {get;set;}
}
public class Bar : IBar
{
private int _id;
private IFoo _foo;
public int Id {get{return _id;} set{_id = value;}}
public IFoo Foo {get{return _foo;} set{_foo = value;}}
}
是否可以指示 Foo 是一个有效的类并默认使用它,我不想使用数据库来存储类类型。
谢谢
罗汉
I am trying to implement my persitent classes using interfaces. I have created the following
public interface IFoo
{
int Id {get;set;}
}
public class Foo : IFoo
{
private int _id;
public int Id {get{return _id;} set{_id = value;}}
}
public interface IBar
{
int Id {get;set;}
IFoo Foo {get;set;}
}
public class Bar : IBar
{
private int _id;
private IFoo _foo;
public int Id {get{return _id;} set{_id = value;}}
public IFoo Foo {get{return _foo;} set{_foo = value;}}
}
Is it possible to indicate that Foo is a valid class and to use it by default, i dont want to use the database to store the class type.
Thanks
Rohan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
鉴别器列始终是必需的,因为 OpenAccess 不知道以后是否会有更有效的实现。 您可以做的是使用直接 Foo 引用作为私有字段并将其公开为 Interface 属性。 setter 中的类转换异常可能会帮助您找到设置错误对象的位置。
希望有帮助,
简
The descriminator column is always necessary because OpenAccess does not know if there might be more valid implementations later. What you can do is to use a direct Foo reference as private field and expose it as Interface property. The class cast exception in the setter might help you to find the places where a wrong object is set.
Hope that helps,
Jan
查看这些链接:
http://www.telerik.com /help/openaccess-orm/classes-persistent-interfaces.html
http://www.telerik.com/help/openaccess-orm/the-.net-data-model-user-defined-interfaces.html
Check out these links:
http://www.telerik.com/help/openaccess-orm/classes-persistent-interfaces.html
http://www.telerik.com/help/openaccess-orm/the-.net-data-model-user-defined-interfaces.html
阅读完 Telerik 指南后,我在他们的论坛上发布了一个问题...
使用接口而不将类类型存储在数据库中
看起来这是不可能的。
after reading through the Telerik guide i posted a question on their forum...
Using Interfaces without storing the Class Type in the database
It looks like its not possible.