GetModelClasses

Hello,

i want to copy a Database from MSSQL to SQLite using TMS Aurelius.
With the following Code it is possible to Copy the the Table "Kanban" from MSSQL to the SQLite Database.

Kanbans:=Manager.Find<TKanban>.List;

  if Kanbans.Count>0 then
  begin
  for I :=0  to Kanbans.Count-1 do
    begin
      ManagerLocal.Replicate(Kanbans.Items[I]);
      ThreadStatusProc((EC/45)*100,(I/ Kanbans.Count)*100);
    end;
  end;
   Kanbans.Free;

The Problem using this apporoach is, that i have to implement this piece of code for every Entity Registered. So when i have changes inside the Model, i have to do a lot of Source Code Update.

So i wondered if it's possible to use the piece of Code bellow somehow to get a List of my Classes and iterate through this List.

class function GetModelClasses(const ModelName: string): TEnumerable<TClass>;

Is this possible and do you have a short example code?

Kind regards,

It's possible. Just iterate through the list of the classes, and get the classes from Aurelius. It should be rather simple, actually, you just need to use the non-generic version of Find:

Entities := Manager.Find(TheCurrentClass).List;

That's right.
Is there a Way to get a List of the all Classes currently registered or registered for a certain model?

Something like

ClassList:=GetModelClasses('Snapshot');

So that i would copy the database like

for i =0 to Classlist.count-1 do 
begin
  Entities :=Manager.Find(Classlist[i]).List;
  //Copy the entities
end;

You can use:

for EntityClass in Manager.Explorer.Hierarchy.Classes do

Thank You, it works

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.