<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How can I use rowCursor more efficiently? in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-can-i-use-rowcursor-more-efficiently/m-p/1319488#M10195</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;If I understand you right, you want to call function from commented area.&lt;/P&gt;&lt;P&gt;So you could do it using Action or Func delegate. Below is sample with Action delegate:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;    static void MyFunction(double param1)
    {
        Console.WriteLine($"Parameter: {param1}");
    }

    // Add an Action delegate as a parameter
public void AggregateMethod(Action&amp;lt;double&amp;gt; action)
        {
            QueuedTask.Run(() =&amp;gt;
            {
                FeatureClassDefinition IntersectSortDef = IntersectSort.GetDefinition();
                QueryFilter qF = new QueryFilter { WhereClause = $@"{FieldName} = {UniqueID}" };

                using (var rowCursor = IntersectSort.Search(qF, false))
                {
                    while (rowCursor.MoveNext())
                    {
                        using (Row row = rowCursor.Current)
                        {    
                            var rArea = row["Shape_Area"];
                           // Invoke the passed action
                           action(rArea);
                        }
                    }
                }
            });
        }


        // Usage example
        AggregateMethod(MyFunction);&lt;/LI-CODE&gt;&lt;P&gt;If you want to return value from function use Func delegate:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;    static bool MyFunction(double param1)
    {
        Console.WriteLine($"Parameter: {param1}");
        return param1 &amp;gt; 0;
    }

    // Add an Action delegate as a parameter
public void AggregateMethod(Func&amp;lt;double, bool&amp;gt; func)
        {
            QueuedTask.Run(() =&amp;gt;
            {
                FeatureClassDefinition IntersectSortDef = IntersectSort.GetDefinition();
                QueryFilter qF = new QueryFilter { WhereClause = $@"{FieldName} = {UniqueID}" };

                using (var rowCursor = IntersectSort.Search(qF, false))
                {
                    while (rowCursor.MoveNext())
                    {
                        using (Row row = rowCursor.Current)
                        {    
                            var rArea = row["Shape_Area"];
                           // Invoke the passed action
                           bool retVal = func(rArea);
                        }
                    }
                }
            });
        }


        // Usage example
        AggregateMethod(MyFunction);&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 17 Aug 2023 09:03:47 GMT</pubDate>
    <dc:creator>GKmieliauskas</dc:creator>
    <dc:date>2023-08-17T09:03:47Z</dc:date>
    <item>
      <title>How can I use rowCursor more efficiently?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-can-i-use-rowcursor-more-efficiently/m-p/1319429#M10194</link>
      <description>&lt;P&gt;I'm creating a tool that would query a dataset and create a query table using a unique ID, then perform some calculations using the query table. Final, it would populate the calculated outputs in an attribute table of a new output feature class. The tools works, but I was wondering if there is a more efficient way of calculating the values and populating the output table. I would like to remove the repetitive method commented below as a separate method, but the problem I'm having is how to find the fields value without having it inside this row cursor loop? Is there a way I can get the field values (e.g.&amp;nbsp;var rArea = row["Shape_Area"]) as the input parameter of the new method? Thanks for your help! Please see a snippet of my code below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public void AggregateMethod()
        {
            QueuedTask.Run(() =&amp;gt;
            {
                FeatureClassDefinition IntersectSortDef = IntersectSort.GetDefinition();
                QueryFilter qF = new QueryFilter { WhereClause = $@"{FieldName} = {UniqueID}" };

                using (var rowCursor = IntersectSort.Search(qF, false))
                {
                    while (rowCursor.MoveNext())
                    {
                        using (Row row = rowCursor.Current)
                        {    
                            var rArea = row["Shape_Area"];
                           //Performing the repetitive calculations here
                           //Ideally, I would like to take this middle part 
                           //and create a separate method with the repetitive 
                            //  calculations.
                      
                        }
                    }
                }
            });

           //return output values 

        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 00:52:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-can-i-use-rowcursor-more-efficiently/m-p/1319429#M10194</guid>
      <dc:creator>tzz_12</dc:creator>
      <dc:date>2023-08-17T00:52:58Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use rowCursor more efficiently?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-can-i-use-rowcursor-more-efficiently/m-p/1319488#M10195</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;If I understand you right, you want to call function from commented area.&lt;/P&gt;&lt;P&gt;So you could do it using Action or Func delegate. Below is sample with Action delegate:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;    static void MyFunction(double param1)
    {
        Console.WriteLine($"Parameter: {param1}");
    }

    // Add an Action delegate as a parameter
public void AggregateMethod(Action&amp;lt;double&amp;gt; action)
        {
            QueuedTask.Run(() =&amp;gt;
            {
                FeatureClassDefinition IntersectSortDef = IntersectSort.GetDefinition();
                QueryFilter qF = new QueryFilter { WhereClause = $@"{FieldName} = {UniqueID}" };

                using (var rowCursor = IntersectSort.Search(qF, false))
                {
                    while (rowCursor.MoveNext())
                    {
                        using (Row row = rowCursor.Current)
                        {    
                            var rArea = row["Shape_Area"];
                           // Invoke the passed action
                           action(rArea);
                        }
                    }
                }
            });
        }


        // Usage example
        AggregateMethod(MyFunction);&lt;/LI-CODE&gt;&lt;P&gt;If you want to return value from function use Func delegate:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;    static bool MyFunction(double param1)
    {
        Console.WriteLine($"Parameter: {param1}");
        return param1 &amp;gt; 0;
    }

    // Add an Action delegate as a parameter
public void AggregateMethod(Func&amp;lt;double, bool&amp;gt; func)
        {
            QueuedTask.Run(() =&amp;gt;
            {
                FeatureClassDefinition IntersectSortDef = IntersectSort.GetDefinition();
                QueryFilter qF = new QueryFilter { WhereClause = $@"{FieldName} = {UniqueID}" };

                using (var rowCursor = IntersectSort.Search(qF, false))
                {
                    while (rowCursor.MoveNext())
                    {
                        using (Row row = rowCursor.Current)
                        {    
                            var rArea = row["Shape_Area"];
                           // Invoke the passed action
                           bool retVal = func(rArea);
                        }
                    }
                }
            });
        }


        // Usage example
        AggregateMethod(MyFunction);&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 17 Aug 2023 09:03:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-can-i-use-rowcursor-more-efficiently/m-p/1319488#M10195</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2023-08-17T09:03:47Z</dc:date>
    </item>
  </channel>
</rss>

