Get Schema and Data in one call

We have a Server developed in Delphi and an ASP.Net client

Server side

// Here the SQL is completely build dynamically, there is no other way!!
// The dataset.SQL is filled and the dataset is opened.

DataStreamer.WriteDataset(Result, dataSet, [woRows, woSchema], -1);

Client Side

DataSet ds = new DataSet();
DataStreamer Streamer = new BinDataStreamer();

        RemoteService RORemoteService = new RemoteService();
        RORemoteService.ServiceName = "HDSUserDataBroker";
        RORemoteService.Message = BinMessageFactory.CreateMessage();
        RORemoteService.Channel = ChannelFactory.CreateChannel();

        RemoteDataAdapter DAAdapter = new RemoteDataAdapter();
        DAAdapter.RemoteService = RORemoteService;
        DAAdapter.DataStreamer = Streamer;

        DAAdapter.SchemaCall.MethodName = "GetLookupDataSet";

        DAAdapter.SchemaCall.Parameters.Clear();
        DAAdapter.SchemaCall.Parameters.Add("Result", "Binary", RemObjects.SDK.ParameterDirection.Result);
        DAAdapter.SchemaCall.Parameters.Add("UsersessionId", "WideString", ParameterDirection.In);
        DAAdapter.SchemaCall.Parameters.Add("LookupFieldSeq", "Integer", ParameterDirection.In);
        DAAdapter.SchemaCall.Parameters.Add("LookupTableFilterSeq", "Int64", ParameterDirection.In);
        DAAdapter.SchemaCall.Parameters.Add("ParentKeyValue", "Int64", ParameterDirection.In);

        DAAdapter.SchemaCall.Parameters.ParameterByName("UsersessionId").Value = UsersessionId;
        DAAdapter.SchemaCall.Parameters.ParameterByName("LookupFieldSeq").Value = FieldSeq;
        DAAdapter.SchemaCall.Parameters.ParameterByName("LookupTableFilterSeq").Value = lookupTableFilterSeq;
        DAAdapter.SchemaCall.Parameters.ParameterByName("ParentKeyValue").Value = ParentKeyValue;

        DAAdapter.DataRequestCall.MethodName = "GetLookupDataSet";

        DAAdapter.DataRequestCall.Parameters.Clear();
        DAAdapter.DataRequestCall.Parameters.Add("Result", "Binary", RemObjects.SDK.ParameterDirection.Result);
        DAAdapter.DataRequestCall.Parameters.Add("UsersessionId", "WideString", ParameterDirection.In);
        DAAdapter.DataRequestCall.Parameters.Add("LookupFieldSeq", "Integer", ParameterDirection.In);
        DAAdapter.DataRequestCall.Parameters.Add("LookupTableFilterSeq", "Int64", ParameterDirection.In);
        DAAdapter.DataRequestCall.Parameters.Add("ParentKeyValue", "Int64", ParameterDirection.In);

        DAAdapter.DataRequestCall.IncomingDataParameter = "Result";

        DAAdapter.DataRequestCall.Parameters.ParameterByName("UsersessionId").Value = UsersessionId;
        DAAdapter.DataRequestCall.Parameters.ParameterByName("LookupFieldSeq").Value = FieldSeq;
        DAAdapter.DataRequestCall.Parameters.ParameterByName("LookupTableFilterSeq").Value = lookupTableFilterSeq;
        DAAdapter.DataRequestCall.Parameters.ParameterByName("ParentKeyValue").Value = ParentKeyValue;

        string[] saString = new string[1];
        saString[0] = lookupTableName;
        DAAdapter.DataRequestCall.Parameters.Add("aTableNameArray", "StringArray", RemObjects.SDK.ParameterDirection.In);
        DAAdapter.DataRequestCall.Parameters.ParameterByName("aTableNameArray").Value = saString;
        DAAdapter.DataRequestCall.OutgoingTableNamesParameter = "aTableNameArray";

        ds.Tables.Add(lookupTableName);
        try
        {
            ---> DAAdapter.FillSchema(ds, saString);
            ---> DAAdapter.Fill(ds, true);
        }
        catch
        {
            throw;      // Reraise exception to get clear message
        }

        return ds.Tables[0];

The two calls from the client side (DAAdapter.FillSchema and DAAdapter.Fill) both result in a complete dataset being sent to the client, which is not what we want (performance).
Can we use just a single call on the client side???

regards
Paul Sjoerdsma

Hello Paul.

As you use custom method (GetLookupDataSet method) to get data then you can return both table Schema and data as a result of this method and then use this result on the client side.

Hope this helps.

Hi Andreyt,

We are returning both data and schema in one call from the server:

DataStreamer.WriteDataset(Result, dataSet, [woRows, woSchema], -1);

However I am unclear which call to use on the client side to get both schema and data in once call. At the moment we are using two calls:

DAAdapter.FillSchema(ds, saString);
DAAdapter.Fill(ds, true);

There must be a single call I can make to replace these two calls, not sure which one though??

regards
Paul

I figured it out, calling
DAAdapter.Fill(ds, true);
will load the schema as well so that’s teh call to use

Hello Paul.

On the client side you can use Fill method as follows:

       DAAdapter.Fill(newdataset,true); << true value allows to fill Schema together with data. This request uses one call. 

after this it is possible to use Schema as follows:

  var schema = fDataModule.DataAdapter.Schema; 

Getter method for Schema property is ReadSchema method that recall schema information if Schema==null or ForceReRead property is true. So, in this case client will use only one call to server side.

Hope this helps.