Professional Documents
Culture Documents
Cesar Romero
Cesar Romero
Cesar Romero
IConnectionFactory = interface(IInterface)
['{71E62C5F-8E39-4654-A595-A9083B5A064F}']
function GetConnection: TFDConnection; overload;
function GetConnection(const ConnectionParams: string):
TFDConnection; overload;
end;
.InjectConstructor(TValue.From<string>(TApplicationSetup.GetErpConnect
ion));
Container.RegisterType<IConnectionFactory,
TConnectionFactory>(DEFAULT_CONNECTION_DEF_NAME)
.AsDefault
.AsSingletonPerThread
.InjectConstructor(TValue.From<string>(TApplicationSetup.GetServiceCon
nection));
end;
procedure TConnectionFactory.CreateConnection;
begin
FConnection := TFDConnection.Create(Self.Owner);
FConnection.LoginPrompt := False;
FConnection.ResourceOptions.MacroCreate := False;
FConnection.ResourceOptions.MacroExpand := False;
FConnection.ResourceOptions.EscapeExpand := False;
FDefaultTransaction := TFDTransaction.Create(Self.Owner);
FDefaultTransaction.Connection := FConnection;
end;
Params := TStringList.Create;
Defer(Params.Free);
Params.Delimiter := ';';
AddConnectionDef(ConnectionDefName, Params);
Result.ConnectionDefName := ConnectionDefName;
Result.Connected := True;
end;
I'm using this for more than one year already in my server Applications with several
simultaneous threads and no problems so far.
Regards,
Cesar Romero