Select to view content in your preferred language

The user-specified map layer does not exist when opening query table .net sdk

878
6
07-18-2023 03:32 AM
RITASHKOUL
Regular Contributor

 

Hi,

I am using query definition which contains multiple tables having the join. 

var queryDefinition = new QueryDef
{
      Tables = @"dbo.Table1 table1
      LEFT JOIN dbo.Table2 table2 ON table1.ID = table2.Table1ID
      LEFT JOIN dbo.Table3 table3 ON table2.ID = table3.Table2ID",
      WhereClause = $"table1.Name = {name}"
};

using var table1Table = table1FeatureLayer.GetTable();
using var database = (Geodatabase)table1Table.GetDatastore();
 
var queryTableDescription = new QueryTableDescription(queryDefinition);
var queryTable = database.OpenQueryTable(queryTableDescription);
 
I can have multiple data sources so I am fetching the database from the feature layer present in the required data source.
 
But when opening the query table I am getting this error:
ArcGIS.Core.Data.Exceptions.GeodatabaseEnterpriseException: 'The user-specified map layer does not exist.'

 

What is the meaning of this error? I am not able to understand.

@Wolf @UmaHarano @GKmieliauskas  @Aashis 

Thanks!

Tags (1)
0 Kudos
6 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

I think problem is related with query definition string. Have you tried to specify fields directly (without table1, table2, table3)?

0 Kudos
RITASHKOUL
Regular Contributor

@GKmieliauskas  No I cant do that since I have same name columns in those tables.

0 Kudos
GKmieliauskas
Esri Regular Contributor

I mean write string like below:

 

var queryDefinition = new QueryDef
{
      Tables = @"dbo.Table1
      LEFT JOIN dbo.Table2 ON dbo.Table1.ID = dbo.Table2.Table1ID
      LEFT JOIN dbo.Table3 ON dbo.Table2.ID = dbo.Table3.Table2ID",
      WhereClause = $"dbo.Table1.Name = {name}"
};

 

Another one thing that "WhereClause" doesn't know about "table1", which is defined in "Tables" string.

0 Kudos
RITASHKOUL
Regular Contributor

@GKmieliauskas Now I have included the database name as well since without that I am getting table not found. But after adding database name I am getting 

ArcGIS.Core.Data.Exceptions.GeodatabaseEnterpriseException: 'The specified attribute column does not exist.'

Even if all the columns mentioned in the sub fields are present in the table.

var queryDefinition = new QueryDef
{
Tables = @"dbname.dbo.Table1
LEFT JOIN dbname.dbo.Table2 ON dbname.dbo.Table1.ID = dbname.dbo.Table2.Table1ID
LEFT JOIN dbname.dbo.Table3 ON dbname.dbo.Table2.ID = dbname.dbo.Table3.Table2ID",
SubFields = "dbname.dbo.Table1.Id, dbname.dbo.Table1.Name"
WhereClause = $"dbo.Table1.Name = {name}"
};

 

0 Kudos
GKmieliauskas
Esri Regular Contributor

Sorry, without database I can't  help you.

Try to comment SubFields and WhereClause properties, then uncomment one by one and check how it works

0 Kudos
Aashis
by Esri Contributor
Esri Contributor

@RITASHKOUL Please refer to the snippets page on setting query defn with Joins.

0 Kudos