Manually fill data to dataset

Hi,

I have created table in DA shema.
Now i try to fill it with some data that not exists in database.

How can i do that in .NET server implementation ?

What dataabstract service event is perfect for that ?

Any sample code will be nice.

Thanks for advance.

Edvin

Hello Edvin.

There are two ways to solve the problem:

  1. Create for table in Schema Modeler custom SQL statement that will return all necessary data. In this no need to change server and client code.
  2. On the server side implement DataService’s virtual method GetData to create custom resultset and return it to user. In this case on the server side it is possible to establish data you need and get it on the client side as usual.

What approach is better for your? Can you explain your case, when you need to fill custom data?

Thanks.

Hi Andrey

Your first recommended solution is not suitable enought.

Your second one is more suitable.
What do you mean with implementing GetData Method ?
Isn’t it already implemented ?
Maybe should i override it ?

Can you write some code to explain ?

Is there third option ?
I’m searching something like ExportedDataTables in Delphi DA server.
Is it possible in .NET ?

Thanks for advance.

Edvin

Hello Edvin.

Sorry for the belated response.

What do you mean with implementing GetData Method ?
Isn’t it already implemented ?
Maybe should i override it ?
Yes, this method is virtual and you can override it. Also you can use custom method to get data. So, the steps to solve the problem are the next:

  1. Open .RODL file and create new operation (f.e. MyCustomGetDataMethod) for DataService with string input parameter “TableName” and Binary Result. If you want to override GetData method then skip this step.

  2. Add for example the next implementation for the method MyCustomGetDataMethod:

public Binary MyCustomGetDataMethod(string TableName)
        {
            Binary result = new Binary();
            ServiceDataStreamer.InitializeStreamer(result, StreamerInitialization.Write);
            SchemaDataTable tableSchema;
            try
            {
                tableSchema = ServiceSchema.DataTables[TableName];
                int maxRecords = -1;

                string[] parNames = null;
                object[] parValues = null;

                IDataReader reader = null;
                try
                {
                    reader = ServiceSchema.NewDataReader(Connection, TableName, null/*as DynSelect*/, null /*as DynWhere*/, parNames, parValues);
                    ServiceDataStreamer.WriteDataReader(reader, tableSchema, maxRecords);
                }
                finally
                {
                    if (reader != null) reader.Close();
                }
            }
            finally
            {
                ServiceDataStreamer.FinalizeStreamer();
            }
            return result;
        }

If you override GetData then please use it’s signature.

  1. Change DataRequestCall property of RemoteDataAdapter if you use custom method:
            this.remoteDataAdapter.DataRequestCall.MethodName = "MyCustomGetDataMethod";
            this.remoteDataAdapter.DataRequestCall.Parameters.Clear();
            this.remoteDataAdapter.DataRequestCall.Parameters.Add("Result", "Binary", RemObjects.SDK.ParameterDirection.Result);
            this.remoteDataAdapter.DataRequestCall.Parameters.Add("TableName", "WideString", RemObjects.SDK.ParameterDirection.In);
            this.remoteDataAdapter.DataRequestCall.Parameters.Add(null, null, RemObjects.SDK.ParameterDirection.Unknown);
            this.remoteDataAdapter.DataRequestCall.Parameters.Add("aTableNameArray", "String", RemObjects.SDK.ParameterDirection.In);
            this.remoteDataAdapter.DataRequestCall.OutgoingTableNamesParameter = "aTableNameArray";
            this.remoteDataAdapter.DataRequestCall.IncomingDataParameter = "Result";
  1. Run the server. Run the client.

I’m searching something like ExportedDataTables in Delphi DA server.
Is it possible in .NET ?
No, RemObjects DataAbstract for .NET doesn’t contain this functionality.

Hope this helps.

Hi Andrey

After more than month working on another project, i came back to problem we discussed.
Your suggestion creating custom GetData method is nice and simple, but is not universal. I need to change RemoteDataAdapter properties.

If i take overriding GetData method then this solution will work with all supported clients like delphi, js and ODATA. Agree ?

First i need to know what methods i need to override for retriving data.
Are getData and getSchema enought ?
Are there any sample project that could help me ?

getSchema returns schema definitions in XML format ?
Is there any documentation how schema is defined in XML ?

Please any info is preferred.

Regards.

Edvin

Hello Edvin.

If i take overriding GetData method then this solution will work with all supported clients like delphi, js and ODATA. Agree ?
GetData method is used to retrieve data. So, if you override it then all types of clients (delphi, js, odata) will call overriden method to retrieve the data.

First i need to know what methods i need to override for retriving data.
Are getData and getSchema enought ?
Are there any sample project that could help me ?
You need to override getData method. getSchema returns the schema referenced by the service to the calling client application. So no need to override getSchema method if you only need to retrieve the data. As example please use code snippet above but change MyCustomGetDataMethod definition to GetData method definition.

getSchema returns schema definitions in XML format ?
Yes, getSchema returns result in XML format.

Is there any documentation how schema is defined in XML ?
Please take a look at the article Documentation | RemObjects Software .

Hope this helps.