Question

I am using Telerik Open Access ORM in my asp.net C# web application. In my app, I have mapped a table entity from database named "Person" as base class and created a Sub Domain Class named "Employee". Then I have applied vertical inheritance for subclass to the Base class and used "Default mapping" for the Employee Sub class.

While querying both Base/Sub class I am getting error :

Error executing query: Telerik.OpenAccess.RT.sql.SQLException: Invalid object name 'Employee'.

These are the lines added to query from the context:

       using (EntitiesModel1 obj = new EntitiesModel1())
        {
            List<Employee> lstEmp = obj.Employees.ToList();
          GridView1.DataSource = lstEmp;
          GridView1.DataBind();
        }

Please help.

Était-ce utile?

La solution

When you specify the Inheritance strategy to be 'Vertical' this implies that each class has it's own physical table. Hence you get the error that 'Employee' table is missing.

If you want to store instances of both Person and Employee in a single table 'Person', you need to use the default Inheritance strategy, which is 'Flat'.

In case you want to create the additional 'Employee' table then you can use the Schema Handler API and let OpenAccess generate the apporpriate ddl.

var context = new EntityDiagram();
var schemaHandler = context.GetSchemaHandler();
var ddl = schemaHandler.CreateUpdateDDLScript(null);
if(string.IsNullOrEmpty(ddl) == false)
   schemaHandler.ExecuteDDLScript(ddl);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top