Hi,
In the ArcGIS Pro 2.2 API Reference Guide i've found this interesting function "CIMSqlQueryDataConnection " but there are no examples of how to use it, i think that this function could be useful to search in a Geodatabase for a subset of data before loading them in the TOC of ArcGIS Pro. i've thought that this function could be useful to apply a Spatial Query or a Query on atttributes before create a Layer in the TOC. Did I get it right?
Below a sample code and a behavior that i don't understand.
internal static Task<CIMDataConnection> _QueryDataConnection01()
{
try
{
return QueuedTask.Run(() =>
{
Geodatabase sde01 = new Geodatabase(new DatabaseConnectionFile(new Uri(@C:\Users\mgeppi\Documents\ArcGIS\Projects\MyProject5\test.sde)));
CIMSqlQueryDataConnection sqldc = new CIMSqlQueryDataConnection()
{
WorkspaceConnectionString = sde01.GetConnectionString(),
GeometryType = esriGeometryType.esriGeometryPoint,
OIDFields = "OBJECTID",
Srid = MapView.Active.Extent.SpatialReference.Wkid.ToString(),
Dataset = "ParkFacilities",
SqlQuery = "select * from [geodb].[dbo].[PARKFACILITIES]",
SpatialReference = MapView.Active.Extent.SpatialReference,
DatasetType = esriDatasetType.esriDTFeatureClass
};
return (CIMDataConnection)sqldc;
});
}
catch (Exception ee)
{
Logger.logger.ErrorFormat("QueryDataConnection01 {0}", ee.Message);
return null;
}
}
i use this function after where "sqldc" is my preview function.
FeatureLayer fLyr = null;
//MapView.Active.DrawingPaused = true;
fLyr = LayerFactory.Instance.CreateFeatureLayer(sqldc, MapView.Active.Map, 0, "Test");
I see that in ArcGIS Pro a new Feature Layer was Created as visible below

But when i try to see the attribute table i'm getting this error and i don't know why.

it would seem like a malformed query
Then my question was, may i have more examples with right use of this class "CIMSqlQueryDataConnection" to make a spatial query or an attribute query before load data in the TOC?
Thank you in advance.
Max