Error while querying inherited class

Thread is closed for posting
2 posts, 0 answers
  1. Praveen
    Praveen avatar
    14 posts
    Member since:
    Oct 2011

    Posted 08 Feb 2013 Link to this post


    I am using latest version of Telerik Open Access ORM in my  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()
    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.

  2. Alexander
    Alexander avatar
    727 posts

    Posted 13 Feb 2013 Link to this post

    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,
    the Telerik team
    Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
Back to Top