Using Interfaces

Thread is closed for posting
3 posts, 1 answers
  1. Rohan
    Rohan avatar
    6 posts
    Member since:
    Apr 2009

    Posted 28 Apr 2009 Link to this post

    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
  2. Answer
    Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 29 Apr 2009 Link to this post

    Hi Rohan,

    If I understood you correctly you do not want to have the Foo discriminator column in the Bar table. I am afraid this is not possible because the reference in the Bar class has type IFoo. If you really do not want this column, then you will have to use directly a reference of type Foo.

    Kind regards,
    Alexander
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Rohan
    Rohan avatar
    6 posts
    Member since:
    Apr 2009

    Posted 29 Apr 2009 Link to this post

    Thanks for you response Alexander.
Back to Top