CIMSqlQueryDataConnection

1021
3
09-20-2018 07:18 AM
MassimilianoGeppi
Esri Contributor

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

0 Kudos
3 Replies
RichRuh
Esri Regular Contributor

CIMSqlQueryDataConnection isn't designed to be used like this.

Your best bet to show a subset of features in a layer is to use FeatureLayer.SetDefinitionQuery (http://prodev.arcgis.com/en/pro-app/sdk/api-reference/#topic11393.html).  These's an example showing how to use this here: ProConcepts Map Authoring · Esri/arcgis-pro-sdk Wiki · GitHub 

--Rich

0 Kudos
MassimilianoGeppi
Esri Contributor

Thank tuo Rush, for your reply

but I need to create feature layers or a mosaic layer only after choosing a subset of data from the geo database, by a query, loading in arcgis pro only a subset of my data.

In pro-concept I only see authoring on all data already loaded in memory its correct?

On the other hand I was hoping that the CIMSqlQueryDataConnection class had been designed to load only a subset of data from geodatase and then create a layer

M.

Ottieni Outlook per iOS<https://aka.ms/o0ukef>

Massimiliano Geppi

Technical Specialist

e-mail mgeppi@esriitalia.it<mailto:mgeppi@esriitalia.it>

tel. (+39) 06.40696.271

fax. (+39) 06.40696.333

Esri Italia S.p.A. - via Casilina, 98 - 00182 Roma - www.esriitalia.it<http://www.esriitalia.it>

Informativa ai sensi del decreto legislativo 30.06.03 n.196 e GDPR Regolamento (UE) 2016/679.

Ai sensi e per gli effetti dell’Articolo 13 del decreto legislativo 196/2003 "Codice in materia di protezione dei dati personali" cosi come novellato dal GDPR (Regolamento UE 2016/679), informiamo che Esri Italia S.p.A. tratta i dati personali da Lei forniti e liberamente comunicati.

Vi informiamo inoltre che Esri Italia, nel rispetto della normativa su indicata, in qualità di Titolare gestisce le mailing list e tutte le informazioni acquisite nel corso della propria attività commerciale esclusivamente per tale finalità.

Potete richiedere, in qualsiasi momento, in via gratuita, la sospensione immediata dell’impiego dei Vostri dati, al fine dell’invio di analoghe comunicazioni, semplicemente inviando una e-mail a gdpr@esriitalia.it<mailto:gdpr@esriitalia.it>.

Riservatezza

Il contenuto di questo messaggio ed ogni eventuale documento allegato è strettamente riservato al Destinatario e qualora, per errore di trasmissione, pervenisse a persona diversa, preghiamo di contattarci immediatamente ed a non aprire, salvare, stampare il contenuto o rendere note a terzi le informazioni in esso contenute, senza autorizzazione. La ritenzione, l'uso indebito e la diffusione non espressamente autorizzata dalla comunicazione potranno comportare la violazione degli art. 616 e seguenti del Codice Penale.

Grazie per la collaborazione.

0 Kudos
RichRuh
Esri Regular Contributor

My example shown above will only load a subset of data from the database.  In fact, it will only fetch those rows that appear within the current map extent (or close to it) *and* meet the query criteria.

0 Kudos