FYI: I am using RO .NET v10.0.0.1611
Hi,
ServiceSchema [and BeforeExecutingGetDataReaderEventHandler] has no references to DataAbstractService itself so it can be consumed by multiple services.
Can you share the code behind the RemObjects.DataAbstract.Server.DataAbstractService.BeforeExecutingGetDataReader?
Any idea why the event gets triggered 2 times, once per DataAbstractService instance (that points to same RemObjects.DataAbstract.Schema.ServiceSchema)
TIA,
Frederic
Hi,
method DataAbstractService.GetDataViaTableRequestFromPlainTable(tableSchema: SchemaDataTable; requestInfo: TableRequestWrapper; streamer: DataStreamer);
begin
...
using reader := ServiceSchema.GetDataReader(self.Connection, tableSchema, requestInfo.DynamicSelectFieldNames, requestInfo.WhereClause, not self.AllowAllFieldsInDynamicWhere,
requestInfo.ParameterNames, requestInfo.ParameterValues, out columnMappings, out command, requestInfo.OrderBy) do begin
...
end;
method ServiceSchema.GetDataReader(...): IDataReader;
begin
..
self.BeforeExecutingGetDataReader:Invoke(self, new BeforeExecutingGetDataReaderEventArgs(command));
...
end;
Note: DAN sources are installed to C:\Program Files (x86)\RemObjects Software\Data Abstract for .NET\Source.
Can you tell me what the
service.BeforeExecutingGetDataReader+=myevent results into?
does this add an event to the schema singleton?
If so would this not mean that each time a single service performs the action that the event gets thrown to each service (=multiple times), even the disposed ones.
Hi,
we have this code in service:
method DataAbstractService.GetDataViaTableRequest(tableName: String; requestInfo: TableRequestWrapper; streamer: DataStreamer; allowPrivateAccess: Boolean);
..
// Get data and write it to the stream}
if assigned(self.BeforeExecutingGetDataReader) then
ServiceSchema.BeforeExecutingGetDataReader += self.BeforeExecutingGetDataReader;
try
..
finally
if assigned(self.BeforeExecutingGetDataReader) then
ServiceSchema.BeforeExecutingGetDataReader -= self.BeforeExecutingGetDataReader;
end;
You are right, better to have personal schema instance for each service.
OK, i will make something that creates an instance per service
Is the Clone() function suitable?
My code would be
private void DataService_BeforeFindServiceSchema(RemObjects.DataAbstract.Server.DataAbstractService sender, RemObjects.DataAbstract.Server.BeforeFindServiceSchemaEventArgs e)
{
RemObjects.DataAbstract.Schema.ServiceSchema schema = this.schemaProvider_.GetSchema();
RemObjects.DataAbstract.Schema.Schema cloneSchema = schema.Clone();
if (cloneSchema is RemObjects.DataAbstract.Schema.ServiceSchema cloneServiceSchema)
e.ServiceSchema = cloneServiceSchema;
}
I assume I will have to rehook the event, correct?
Call daSvc_.BeforeExecutingGetDataReader=OnBeforeExecutingGetDataReader after the schema has effectively changed.
What happens if the service event is hooked before the service uses a schema? (i think this is the case)
Note : I don’t set the DataAbstractService.ServiceSchema property. This is what the debugger shows at the time I hook the event
![]()
FYI: Clone is not the way to go, I get an object of a different type
![]()
Hi,
the easiest way - save current schema with SaveTo* methods and then load saved data with LoadFrom* methods like
RemObjects.DataAbstract.Schema.ServiceSchema cloneSchema = new RemObjects.DataAbstract.Schema.ServiceSchema();
cloneSchema.LoadFromJson(schema.SaveToJson);
Logged as bugs://D19672.
bugs://D19672 was closed as fixed.
Hi,
I refactored my code so each service has a separate instance of the ServiceSchema and the issue does not occur anymore.
Wouldn’t it be cleaner design if the event was triggered by/attached to the service instance instead of the service schema?
It would eliminate the restriction that you cannot use a singleton serviceschema
Hi,
current behavior was implemented 20 years ago so we can’t change anything because it will be a breaking change …
Hi, what exactly does “was closed as fixed” mean. I have a personal download SDK build 1628.
Are the events attached to a service / schema working differently?
Is cloning still needed?
Note: One of my big issues still is unexplained events that get triggered
Hi Frederic,
These events have most likely been fixed, but your current 1628 build doesn’t include that fix.
We will upload a new 1628 build to your account within the next few hours.
please check on it?