Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

How to ad a TGUID/TSMARTGUID Generator?

 Post Reply Post Reply
Author
Vitale Fabio View Drop Down
New Member
New Member
Avatar

Joined: 10 May 2016
Posts: 6
Post Options Post Options   Quote Vitale Fabio Quote  Post ReplyReply Direct Link To This Post Topic: How to ad a TGUID/TSMARTGUID Generator?
    Posted: 17 Dec 2019 at 9:15am
How to define table fileds  and generator to have ID fields defined as GUIDs?
For example say I have a table with field ID defined as Primary Key VARCHAR(32).

I would like that the generated entity has the following attribute:

[Id('FId', TIdGenerator.SmattGuid)]

How can I obtain this?

Back to Top
Vitale Fabio View Drop Down
New Member
New Member
Avatar

Joined: 10 May 2016
Posts: 6
Post Options Post Options   Quote Vitale Fabio Quote  Post ReplyReply Direct Link To This Post Posted: 17 Dec 2019 at 4:47pm
I have found the solution on this forum:
How to set custom TidGenerator from DataModeler:
You can use Data Modeler customization script feature: http://www.tmssoftware.biz/business/dmodeler/doc/web/customization-script.html



Back to Top
Kaeswurm Thomas View Drop Down
Member
Member
Avatar

Joined: 24 Jul 2014
Posts: 61
Post Options Post Options   Quote Kaeswurm Thomas Quote  Post ReplyReply Direct Link To This Post Posted: 14 Mar 2020 at 11:21am
How do you do it? In OnClassGenerated Event
Can you show an example?
Back to Top
Kaeswurm Thomas View Drop Down
Member
Member
Avatar

Joined: 24 Jul 2014
Posts: 61
Post Options Post Options   Quote Kaeswurm Thomas Quote  Post ReplyReply Direct Link To This Post Posted: 14 Mar 2020 at 11:22am
I want to set the generator to none for TGuid columns
Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2786
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 17 Mar 2020 at 11:36am
Yes, using OnClassGenerated. Here is an example:

procedure OnClassGenerated(Args: TClassGeneratedArgs);
var
  Att: TCodeAttributeDeclaration;
  I: Integer;
begin                                
  for I := 0 to Args.CodeType.CustomAttributes.Count - 1 do
  begin
    Att := Args.CodeType.CustomAttributes.Items;
    if (Att.Name = 'Id') and (Att.Arguments.Count > 1) then
    begin
      TCodeSnippetExpression(Att.Arguments.Items[1].Value)
        .Value := 'TIdGenerator.SmartGuid';
    end;                                      
  end;                   
end;     
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down