views:

223

answers:

3

Hi there,

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

A: 

Hi there, 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.

Rohan West
+2  A: 

Hi Rohan,

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