This is a migrated thread and some comments may be shown as answers.

Use interfaces of the models in OpenAccessContext

1 Answer 28 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Christiaan Molendijk
Top achievements
Rank 1
Christiaan Molendijk asked on 04 Dec 2014, 10:48 AM
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.

1 Answer, 1 is accepted

Sort by
0
Kaloyan Nikolov
Telerik team
answered on 05 Dec 2014, 10:11 AM
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.
 
Tags
Getting Started
Asked by
Christiaan Molendijk
Top achievements
Rank 1
Answers by
Kaloyan Nikolov
Telerik team
Share this question
or