public KnowledgeGraphObjectValue BindParameters {get;}
Public ReadOnly Property BindParameters As KnowledgeGraphObjectValue
public KnowledgeGraphObjectValue BindParameters {get;}
Public ReadOnly Property BindParameters As KnowledgeGraphObjectValue
Exception | Description |
---|---|
ArcGIS.Core.CalledOnWrongThreadException | This method or property must be called within the lambda passed to QueuedTask.Run. |
QueuedTask.Run(async () => { //assume we have, in this case, a list of ids (perhaps retrieved //via a selection, hardcoded (like here), etc. var oids = new List<long>() { 3,4,7,8,9,11,12,14,15,19,21,25,29, 31,32,36,37,51,53,54,55,56,59,63,75,78,80,84,86,88,96,97,98,101, 103,106}; //In the query, we refer to the "bind parameter" with the //"$" and a variable name - '$object_ids' in this example var qry = @"MATCH (p:PhoneNumber) " + @" WHERE p.objectid IN $object_ids " + @"RETURN p"; //we provide the values to be substituted for the variable via the //KnowledgeGraphQueryFilter BindParameter property... var kg_qry_filter = new KnowledgeGraphQueryFilter() { QueryText = qry }; //the bind parameter added to the query filter must refer to //the variable name used in the query string (without the "$") //Note: //Collections must be converted to a KnowledgeGraphArrayValue before //being assigned to a BindParameter var kg_oid_array = new KnowledgeGraphArrayValue(); kg_oid_array.AddRange(oids); oids.Clear(); kg_qry_filter.BindParameters["object_ids"] = kg_oid_array; //submit the query using (var kgRowCursor = kg.SubmitQuery(kg_qry_filter)) { //wait for rows to be returned asynchronously from the server while (await kgRowCursor.WaitForRowsAsync()) { //get the rows using "standard" move next while (kgRowCursor.MoveNext()) { //current row is accessible via ".Current" prop of the cursor using (var graphRow = kgRowCursor.Current) { var cell_phone = graphRow[0] as KnowledgeGraphEntityValue; var oid = cell_phone.GetObjectID(); var name = (string)cell_phone["FULL_NAME"]; var ph_number = (string)cell_phone["PHONE_NUMBER"]; System.Diagnostics.Debug.WriteLine( $"[{oid}] {name}, {ph_number}"); } } } } });
QueuedTask.Run(async () => { //assume we have, in this case, a list of ids (perhaps retrieved //via a selection, hardcoded (like here), etc. var oids = new List<long>() { 3,4,7,8,9,11,12,14,15,19,21,25,29, 31,32,36,37,51,53,54,55,56,59,63,75,78,80,84,86,88,96,97,98,101, 103,106}; //In the query, we refer to the "bind parameter" with the //"$" and a variable name - '$object_ids' and '$sel_geom' //in this example var qry = @"MATCH (p:PhoneNumber) " + @"WHERE p.objectid IN $object_ids AND " + @"esri.graph.ST_Intersects($sel_geom, p.shape) " + @"RETURN p"; //create a KG query filter var kg_qry_filter = new KnowledgeGraphQueryFilter() { QueryText = qry }; //the bind parameter added to the query filter must refer to //the variable name used in the query string (without the "$") //Note: //Collections must be converted to a KnowledgeGraphArrayValue before //being assigned to a BindParameter var kg_oid_array = new KnowledgeGraphArrayValue(); kg_oid_array.AddRange(oids); kg_qry_filter.BindParameters["object_ids"] = kg_oid_array; kg_qry_filter.BindParameters["sel_geom"] = poly; oids.Clear(); //submit the query using (var kgRowCursor = kg.SubmitQuery(kg_qry_filter)) { //wait for rows to be returned asynchronously from the server while (await kgRowCursor.WaitForRowsAsync()) { //get the rows using "standard" move next while (kgRowCursor.MoveNext()) { //current row is accessible via ".Current" prop of the cursor using (var graphRow = kgRowCursor.Current) { #region Process Row var cell_phone = graphRow[0] as KnowledgeGraphEntityValue; var oid = cell_phone.GetObjectID(); var name = (string)cell_phone["FULL_NAME"]; var ph_number = (string)cell_phone["PHONE_NUMBER"]; System.Diagnostics.Debug.WriteLine( $"[{oid}] {name}, {ph_number}");
Target Platforms: Windows 11, Windows 10