Otis wrote:
Can't be done. You can't do this in code:
class A
{
}
class B:A
{
}
A a = new A();
B b = (B)a;
......
Thank you for responding. But I'm not quite tyring to do it the way you have pointed out.
I'm just trying to follow the examples that are provided in the docs for LLBL Pro.
From a real world use of entities as they mature through time, an employee would be created and stored in the database. After a while (maybe years) that employee is promoted to manager. I just want to add a record in the manager table that refrences the employee. I don't want to delete the employee and create a new manager entity with the same data because the employee (over time) has lots of other references to other items in the database. I have tried code like this.....
class Employee
{
}
class Manager:Employee
{
}
Employee emp = new Employee();
emp.SetSomeData;
adapter.SaveEntity(emp);
///Some time passes... Years go by and the diligent employee gets promoted... :-)
Manager man = new Manager();
man.ID = emp.ID; // (Keeping the same key so other references will not break)
man.Data = emp.Data; //Manually map data from employee to manager
man.ExtraManagerData = SomeManagerData;
adapter.SaveEntity(man); //this will throw dup key exception.
I would like to somehow have the Generated classes be able to handle this situation. If adding a new Subtype, it could check if it needs to create entries in both tables, if so then do that, if the Supertype already exists then just create an instance of the sub type that references the Supertype.
I think that from a business (maybe not technical) point of view, this situation occurs quite often. It seams more natural (to me anyway) to follow the workflow I explained here.
Anyone else have thoughts on this??
Thanks for listening.
Chris