Persistent interface

4 posts, 0 answers
  1. Markus
    Markus avatar
    40 posts
    Member since:
    Sep 2008

    Posted 17 Apr 2012 Link to this post

    Hello,

    how do I make an interface persistent with FluentMapping? In old API it was possible an required columns where automatically created ( object_id and object_class).

    An example:
    public interface IOwner
        {
            int Id { get; set; }
            string Name { get; set; }
        }
     
    public class Company : IOwner
        {
            public int Id { get; set; }
     
            public string Name { get; set; }
    }
     
     public class User : IOwner
        {
            public int Id { get; set; }
     
            public string Name { get; set; }
    }
     
     public class Resource
        {
     
            public int Id { get; set; }
     
            public string Key{ get; set; }
           
            public IOwner Owner { get; set; }   //can be User or Company
    }

  2. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 20 Apr 2012 Link to this post

    Hi Markus,

     Currently there is no explicit handling for the interfaces themselves. If your classes are inheriting an interface and there are some properties coming from that interface you will have to manually map them in each of the classes that derive from the interface.

    Greetings,
    Petar
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the OpenAccess ORM, subscribe to their blog feed now.
  3. DevCraft banner
  4. Markus
    Markus avatar
    40 posts
    Member since:
    Sep 2008

    Posted 23 Apr 2012 Link to this post

    Hello Petar,

    thanks for your answer. But I think you misunderstood my question. It was not concerning the implementing classes. It was about the referencing class 'Resource'. In old API OpenAccess generated two columns ( object_id and object_class_id ) for the referencing field 'Owner', because it is an interface and target object could be of many class types. OpenAccess has automatically resolved the object reference when accessing the property. It was also possible to define valid classes. Descriped in Programmer's Reference in Section 'Mapping an Interface or Object Reference' (old API).

    Regards,
    Markus
  5. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 26 Apr 2012 Link to this post

    Hello Markus,

     Unfortunately as I said in my previous post we are not providing any additional handling for interfaces. If you would like to achieve the same result you will have to provide those columns manually.

    Kind regards,
    Petar
    the Telerik team
    Follow @OpenAccessORM Twitter channel to get first the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
Back to Top