Migrating Data Abstract Delphi Server to .net console Server

Im migrating a DA Delphi server to Oxygene .net console server.

Theres any sample (not using Winforms) for that?

I need to undesrtand how to create a Connection, schema, driver manager and load .schema , .connection files at runtime.

Also need to understand how to migrate that code (running at the server side) in a Oxygene dot net server.

  lConnection : IDAConnection;
  lQuery      : IDADataset;
  dw          : TDAWhereBuilder;
    lConnection := ServerDataModule.ConnectionManager.NewConnection(fDBConexion);
    if not lConnection.InTransaction then lConnection.BeginTransaction;
    lQuery        := SchemaGetDataset(lConnection, ServerDataModule.Schema, 'TABLA');
    dw            := lQuery.DynamicWhere;
    dw.Expression := dw.NewBinaryExpression('', 'IDTABLA',  dboEqual, 100);
    lQuery.Active := True;
    result  := lQuery.FieldByName('NAME').AsString;
    if lConnection.InTransaction then lConnection.CommitTransaction;
    on e:exception do
      if lConnection.InTransaction then lConnection.RollbackTransaction;

Which drivers can use to MS SQL server and Postgres server on dot net schema?

DAServerServer.zip (50.5 KB)
This is a simple server app created by the New Project Wizard.
All loading/initialization stuff is done by the ApplicationServer class ( https://docs.remotingsdk.com/Servers/Concepts/ApplicationServerClassNet/ )
Depending on command line arguments the server app can run as a WinForms app, a console app or as a Windows Service

Where exactly this code is run? Ie is it run in a DataService method or somewhere else?

For MS SQL server - MSSQL.NET or MSSQL2012.NET driver.

For PostgreSQL - NPGSQL.NET. Please note that for this driver you’ll have to deploy additional files with your server app (can be found in “…\RemObjects Software\Data Abstract for .NET\Bin\Npgsql” ) - Npgsql.dll and Mono.Security.dll on Windows and Npgsql.dll only on Mac / Linux

Both places. To access local data in the server I use that approach and in a Service Method also, to fill an array an return, be example. Why is important where it run? You make my doubt if I understand your question. Is not only relevant it run at server side?

Bets regards.

Well, the code by itself looks very old-fashioned - it doesn’t use some of the newer DA concepts like LocalDataAdapter instead of manual connection management.
The difference is that:

  1. If it is run from within any service method then we can use currently existing service to instantiate our very own DataService instance to access data via it and not worry about connections, schemas etc
  2. If it is run from a DataService method where we already have a connection and a Schema - we can use another approach to access data

It is possible to use approach like the one in your code. but it would bypass any data access logging and validation.

I cant find

lConnection : IDAConnection;
  lQuery      : IDADataset;
  dw          : TDAWhereBuilder;

in DA for .net library.

If for use in that approach need another interface or component names can please just translate that little sample code to DA for net library? I have a lot of code using that way and need working ASAP.

After that will analyze and migrate to the approach you explain before.

Will wait your answer please, thanks!

This is the sample code.

What it does:

  • It loads a Schema named “WinFormsApplication12Dataset”
  • Composes a DynamicWhere condition (Field named Id should be equal to 1105)
  • Opens a connection named “PCTrade-SQLite”
  • Opens data reader on the Schema table named Orders with DynamicWhere condition applied. Note that it only reads fields Id and OrderDate
  • Reads data
  • Disposes DB command, closes connection and releases it back to the pool

I used different table and field name to test this code on our sample database to be 100% sure that it works

method Test(): DateTime;
  var serviceSchema := RemObjects.DataAbstract.Server.SchemaAccess.RetrieveCachedSchema("WinFormsApplication12Dataset");

  var whereCondition := new RemObjects.DataAbstract.Expressions.BinaryExpression(new RemObjects.DataAbstract.Expressions.FieldExpression("Id"), 1105, RemObjects.DataAbstract.Expressions.BinaryOperator.Equal);

  var connection := RemObjects.DataAbstract.Server.Engine.ConnectionManager.AcquireConnection("PCTrade-SQLite", false);

    var columnMappings: RemObjects.DataAbstract.Schema.SchemaColumnMappingCollection;
    var command: System.Data.IDbCommand;
      using reader := serviceSchema.GetDataReader(connection, "Orders", [ "Id", "OrderDate" ], whereCondition.ToXmlNode(), nil, nil, out columnMappings, out command) do begin
        exit reader["OrderDate"] as DateTime;


Theres no transaction management?

You can add if needed. Connection object in .NET provides almost the same transaction API as in Delphi:

// Transaction support
method BeginTransaction(isolationLevel: IsolationLevel): Int32;
method BeginTransaction(): Int32;
method CommitTransaction();
method RollbackTransaction();
property InTransaction: Boolean read;
property CurrentTransaction: IDbTransaction read;