There is no way to do that with Aurelius and I don't think it's desired to do so. It's not trivial to simply convert one object from one class to another, and it doesn't make sense from OOP point of view.
You should do that outside Aurelius scope, by manually updating the discriminator column value and updating/clearing all the other needed table columns.
Well, I got your point, but it would help me a lot, for other things to, if your CopyFieldValues would start like this:
// >>>
// Assert(FromObj.ClassType = ToObj.ClassType);
//// Assert((FromObj.ClassType = ToObj.ClassType) or (ToObj.InheritsFrom(FromObj.ClassType)));
// Members := GetClassStateMembers(FromObj.ClassType, True, False);
if not ToObj.InheritsFrom(FromObj.ClassType) then
begin
hClass := nil;
var hEntType: TEntityType;
hEntType := GetEntityType(FromObj);
while Assigned(hEntType) do
if not ToObj.InheritsFrom(hEntType.OriginClass) then
hEntType := hEntType.Parent
else
begin
hClass := hEntType.OriginClass;
break;
end;
end
else
hClass := FromObj.ClassType;
Assert(Assigned(hClass));
Members := GetClassStateMembers(hClass, True, False);
// <<<
as you see, your code is commented (the already commented assertions is double-commented )
or better, CopyFieldValues should be extracted and get the Class by Parm.
So you could also check with an Assertion, that this fits and we could enter the parent-class from outside
Sorry, I didn't understand your last paragraph. The code was commented for a reason, note that CopyFieldValues is mostly an "internal" explorer method and not designed or created to be used directly.