Use interfaces of the models in OpenAccessContext

2 posts, 0 answers
  1. Christiaan Molendijk
    Christiaan Molendijk avatar
    1 posts
    Member since:
    Feb 2010

    Posted 04 Dec 2014 Link to this post

    I like to know if it is possible to use interfaces to define your models in the OpenAccessContext.

    So now we have the following code.

    public partial class DataContext : OpenAccessContext
       {
           static MetadataContainer metadataContainer = new DataMetadataSource().GetModel();
           static BackendConfiguration backendConfiguration = new BackendConfiguration()
           {
               Backend = "mssql"
           };
           private const string DbConnection = "connectionID";
           public DataContext()
               : base( DbConnection, backendConfiguration, metadataContainer )
           {
           }
     
           public IQueryable<Product> Products
           {
               get
               {
                   return this.GetAll<Product>();
               }
           }
     
           public IQueryable<Category> Categories
           {
               get
               {
                   return this.GetAll<Category>();
               }
           }
           // Rest of the code 
       }

    Is it possible to change it into:

    public partial class DataContext : OpenAccessContext
       {
           static MetadataContainer metadataContainer = new DataMetadataSource().GetModel();
           static BackendConfiguration backendConfiguration = new BackendConfiguration()
           {
               Backend = "mssql"
           };
           private const string DbConnection = "connectionID";
           public DataContext()
               : base( DbConnection, backendConfiguration, metadataContainer )
           {
           }
     
           public IQueryable<IProduct> Products
           {
               get
               {
                   return this.GetAll<IProduct>();
               }
           }
     
           public IQueryable<ICategory> Categories
           {
               get
               {
                   return this.GetAll<ICategory>();
               }
           }
           // Rest of the code 
       }

    So that the IQueryable also use the interfaces of the models.
  2. Kaloyan Nikolov
    Admin
    Kaloyan Nikolov avatar
    118 posts

    Posted 05 Dec 2014 Link to this post

    Hello Christiaan,

    Unfortunately Telerik Data Access doesn't support this case at the moment. You will not be able to use the GetAll<>() method with other types than the classes defined in your model. 

    Should you have any other questions do not hesitate to get back to us. 

    Regards,
    Kaloyan Nikolov
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  3. DevCraft banner
Back to Top