I want to create IDBConnection on the fly using an anonymous method. Am I doing it right in the following code?
function(const ADBConnStr: String): IDBConnection
begin
var LAdaptedConn := TFDConnection.Create(nil);
LAdaptedConn.Params.CommaText := ADBConnStr;
var LAureliusConn := TAureliusConnection.Create(nil);
LAureliusConn.AdaptedConnection := LAdaptedConn;
LAureliusConn.AdapterName := 'FireDac';
try
Result := LAureliusConn.CreateConnection;
finally
LAureliusConn.Free; // <------ can I do this here????
LAdaptedConn.Free; // <------ can I do this here????
end;
end;