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

Error while querying inherited class

1 Answer 80 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Praveen
Top achievements
Rank 1
Praveen asked on 08 Feb 2013, 10:42 AM
Hi,

I am using latest version of Telerik Open Access ORM in my ASP.net  C# web application. 
In my EntitiesModel1.rlinq , I have  mapped a table named "Customer " from a database. Then I have created a domain class named "SubCustomer" and added anew property field named "SubName : String" into it. Then deleted default property filed from the domain class. Then I have applied inheritance for Customer-sub customer classes. So the inheritance arrow pointing from  SubCustomer to Customer entity now.
  
I have then applied vertical inheritance stuff to SubCustomer class and mapped "SubName" field with "CustomerName" field in Customer Class using "Default mapping". The Update from database model and validate all process have been completed successfully without having any error or warning.

While deploying  this context in my web application and querying like :

  using (EntitiesModel1 context = new EntitiesModel1())
            {             
                List<SubCustomer> lstCustomer = (from entity in context.SubCustomer
                                            select entity).ToList();
            }

I am getting an error:

 Error executing query: Telerik.OpenAccess.RT.sql.SQLException: Invalid object name 'SubCustomer.
   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeQuery()
   at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeQuery()
   at OpenAccessRuntime.Relational.fetch.FetchResultImp.Execute()
SQL:
SELECT a.[CustomerID] AS COL1, b.[voa_class] AS COL2, a.[SubName] AS COL3, b.

I have tried to query "Customer" entity as well  but getting the same error.
Please help.

Regards,
Praveen.

1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 13 Feb 2013, 08:31 AM
Hello Praveen,

This error means that the table with name SubCustomer is not available in the database.
As you are using vertical inheritance strategy, this means that each class is mapped to separate table. So OpenAccess assumes that your class SubCustomer is mapped to a table named SubCustomer. However, this table is not present in your database by default, so you need to create it by running the Update Database From Model wizard. This will add the needed tables to your database and should fix the error at runtime.

Kind regards,
Alexander
the Telerik team
Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
Tags
General Discussions
Asked by
Praveen
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or