2009-04-29 56 views
1

我想实现我的persitent类使用接口。我创建了以下如何使用接口与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是一个有效的类,默认情况下使用它,我不希望使用数据库来存储类类型。

感谢

罗汉

回答

2

descriminator列始终是必需的,因为OpenAccess不知道以后是否有更多有效的实现。你可以做的是使用一个直接的Foo引用作为私有字段并将其作为接口属性公开。 setter中的类转换异常可能会帮助您找到设置了错误对象的地方。

希望帮助,