Hi!
I have an old project being ported to Aurelius. I have a class like this (simplified here)
[Entity]
[Table('users')]
[Id('FId', TIdGenerator.IdentityOrSequence)]
TUser = class
private
...
FRoles: TStringList;
public
..
property Roles: TStringList read FRoles write FRoles;
end;
My question is: How to store the TStringlist as CommaText in the DB?
I would like to retain the property as is, because is widely used in the application (if possible).
wlandgraf
(Wagner Landgraf)
2
Hi Dino,
Unfortunately, there is current no way to direct map a TStringList type to the database using Aurelius.
Why not add a property that reads the StringLists Text and is mapped to a MEMO in the DB?
Exactly, I post here my solution for future reference :)
I added a new property
private
[Transient]
FRoles: TStringList;
[Column('USER_GROUP', [TColumnProp.Required], 255)]
FUserGroup: string;
procedure SetRoles(const Value: TStringList);
function GetRoles: TStringList;
public
property Roles: TStringList read GetRoles write SetRoles;
property PartnerGroup: string read FPartnerGroup write FPartnerGroup;
...
function TPartner.GetRoles: TStringList;
begin
FRoles.CommaText := FUserGroup;
Result := FRoles;
end;
procedure TPartner.SetRoles(const Value: TStringList);
begin
self.UserGroup := Value.CommaText;
end;
It's not perfect, but solves the problem while migrating the (tons of) code. :)