FYI 1: For a simple query the query gets executed by sql server but GetData breakpoint is not hit and my logging code in it does not trigger
FYI 2: I cheated by using a generated _TableDefinitions.cs file which did not belong to this service however when using the correct generated class it also fails
method LinqRemoteDataAdapter.FetchData(tableRequest: array of RemObjects.DataAbstract.Server.TableRequestInfo; tableNames: array of String; fillMethod: Action<Int32, array of Int32, IDataReader>);
begin
..
self.DataRequestCall.MakeRequest();
..
end;
FYI: The second point (UnknownSqlMacroIdentifier) already works with the LinqLocalDataAdapter. I just have to move my resolveIdentifier code from GetTable (which does not get called) to some code that gets called
There are two different members named GetData on DataAbstractService: the public virtual one you override, which the invoker calls on a network request, and a non-virtual explicit IDataAbstractLocalServiceAccess.GetData the one LinqLocalDataAdapter actually calls.
That is why your override is never entered, and no constructor changes it.
You don’t need a loopback connection though. Both things you asked for work locally, from your service constructor
// 1. the SQL, after table names and macros are resolved
`this.BeforeExecutingGetDataReader += (sender, e) =>`
`{`
` // e.Command.CommandText`
`};`
`// 2. resolving a {TARGETTABLE} macro in the schema statement, per request`
`this.AllowCustomSqlMacros = true; // otherwise the handler raises`
`this.UnknownSqlMacroIdentifier += (sender, e) =>`
`{`
` if (e.Identifier != "TARGETTABLE") return;`
` e.Value = ResolveIdentifier(e.Identifier);`
` e.Processed = true;`
`};`
The macro is resolved at connection level, independently of the adapter what broke it for you is only where you subscribed: inside your GetData override that code never runs on the local path.
Attached is a small console sample: one LinqLocalDataAdapter, the macro resolving the table name per request, and the SQL logged. It runs the same query twice against two different tables.