It seems that the problem is caused in “PlainTableSqlStatement”.
Initially I tried to use a SQL statement and then I switched to a stored procedure (probably the schema modeler in case of exception restores the previous value, in this case SQL).
Restarting the project from stored procedure I have this error:
This code line puts the data adapter in the mode where it uses DynamicWhere to express data requests.
In this mode one can request data from Delphi servers (that don’t support DA SQL) and from StoredProdecure-based tables.
Limitations are that in this mode queries cannot contain JOIN, GROP-BY or ORDER statements.
Additionally StoredProcedure-based tables also have a very significant limitation:
One cannot use any where conditions in the queries to such tables. This means that this query will be executed successfully:
var query = from x in this.fDataModule.DataAdapter.GetTable<TestTable>
(new DataParameter[] { new DataParameter() { Name = "Parm1", Value = "val1" } })
select x;
while this one will fail:
var query = from x in this.fDataModule.DataAdapter.GetTable<TestTable>
(new DataParameter[] { new DataParameter() { Name = "Parm1", Value = "val1" } })
where x.F1 == "AAA"
select x;
The failing metadata request for StoredProcedure statement type is a bug. I’ll log it and will try to fix ASAP.
This is how I added the Schema Table definition:
Open the Schema Modeler by dbl-clicking the .daSchema file
Right-click the Tables node and select Add command in the context menu
Change the table name to TestTable
Expand the table node and right-click the Statements sub-node
Select Add command in the context menu
For the statement added change Statement Type to SQL
Set the SQL statement to
EXEC [dbo].[TEST_SP] :Parm1
Switch to the Mappings tab
When asked to recreated parameters confirm the action
Double-check the parameter type (set the correct one if needed)
Go back to the statement SQL statement and press the ‘Validate’ button
Open the ‘Mappings’ tab and press the ‘Recreate Fields’ button
Steps 2-12 can be simplified - just drag the stored procedure form the Connection Manager to the Tables node. This will do essentially the same.
This is the client code tat uses RemoteDataAdapter:
var adapter = new RemoteDataAdapter("http://localhost:8099/bin");
var table = new DataTable("TestTable");
adapter.Fill(table, new TableRequestInfoV5 { IncludeSchema = true, Parameters = new DataParameter[] { new DataParameter() { Name = "Parm1", Value = "val1" } } }, true);
MessageBox.Show($"{table.Rows.Count} row(s) fetched");