<?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 ServiceFeatureTable not properly initialized in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/servicefeaturetable-not-properly-initialized/m-p/403894#M4804</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We're noticing strange initialization behavior of ServiceFeatureTable when layer is not added to map and Map is not added to MapView.&lt;/P&gt;&lt;P&gt;We cannot query ServiceFeatureTable and cannot add new features.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ArcGIS Runtime version: 10.2.6.0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//create layer and initialize&lt;/P&gt;&lt;P&gt;var layer = new FeatureLayer(uri);&lt;/P&gt;&lt;P&gt;await layer.InitializeAsync();&lt;/P&gt;&lt;P&gt;//try query table&lt;/P&gt;&lt;P&gt;var table = layer.FeatureTable as ServiceFeatureTable;&lt;/P&gt;&lt;P&gt;var result = await table.QueryAsync(filter);&lt;/P&gt;&lt;P&gt;//last line fails with exception that table is not initialized, even though table.isInitialized == true&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//try create new feature&lt;/P&gt;&lt;P&gt;var feature= table.CreateNew();&lt;/P&gt;&lt;P&gt;//last line fails with null reference exception. In debug mode we see clearly that Schema and some other properties are missing even though table.isInitialized == true&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Everything works if we add this layer to a Map and MapView in UI (at runtime adding the layer only to Map which is not visible in UI does not solve the problem) and wait for MapView.LayersLoadedAsync().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the question is, how should we propely initialize ServiceFeatureTable without adding layer to the UI? What does FeatureLayer.InitializeAsync() do if we still have to wait for MapView.LayersLoadedAsync()?&lt;/P&gt;&lt;P&gt;Is it a bug or expected behavior?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think the question is related to this one, but the answer that was marked as correct seems not to be correct in our case (when feature table is used without MapView)&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/message/462006"&gt;Re: Proper Way to Edit Service Feature Table Without Map&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Nov 2015 15:34:04 GMT</pubDate>
    <dc:creator>AndriusB</dc:creator>
    <dc:date>2015-11-10T15:34:04Z</dc:date>
    <item>
      <title>ServiceFeatureTable not properly initialized</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/servicefeaturetable-not-properly-initialized/m-p/403894#M4804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We're noticing strange initialization behavior of ServiceFeatureTable when layer is not added to map and Map is not added to MapView.&lt;/P&gt;&lt;P&gt;We cannot query ServiceFeatureTable and cannot add new features.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ArcGIS Runtime version: 10.2.6.0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//create layer and initialize&lt;/P&gt;&lt;P&gt;var layer = new FeatureLayer(uri);&lt;/P&gt;&lt;P&gt;await layer.InitializeAsync();&lt;/P&gt;&lt;P&gt;//try query table&lt;/P&gt;&lt;P&gt;var table = layer.FeatureTable as ServiceFeatureTable;&lt;/P&gt;&lt;P&gt;var result = await table.QueryAsync(filter);&lt;/P&gt;&lt;P&gt;//last line fails with exception that table is not initialized, even though table.isInitialized == true&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//try create new feature&lt;/P&gt;&lt;P&gt;var feature= table.CreateNew();&lt;/P&gt;&lt;P&gt;//last line fails with null reference exception. In debug mode we see clearly that Schema and some other properties are missing even though table.isInitialized == true&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Everything works if we add this layer to a Map and MapView in UI (at runtime adding the layer only to Map which is not visible in UI does not solve the problem) and wait for MapView.LayersLoadedAsync().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the question is, how should we propely initialize ServiceFeatureTable without adding layer to the UI? What does FeatureLayer.InitializeAsync() do if we still have to wait for MapView.LayersLoadedAsync()?&lt;/P&gt;&lt;P&gt;Is it a bug or expected behavior?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think the question is related to this one, but the answer that was marked as correct seems not to be correct in our case (when feature table is used without MapView)&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/message/462006"&gt;Re: Proper Way to Edit Service Feature Table Without Map&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Nov 2015 15:34:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/servicefeaturetable-not-properly-initialized/m-p/403894#M4804</guid>
      <dc:creator>AndriusB</dc:creator>
      <dc:date>2015-11-10T15:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: ServiceFeatureTable not properly initialized</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/servicefeaturetable-not-properly-initialized/m-p/403895#M4805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I typically use ServiceFeatureTable.OpenAsync(...).&amp;nbsp; Here is an quick snippet that I might use.&amp;nbsp; I also initialize the out fields because you don't get them by default. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;// Initialize&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;var _sft = await ServiceFeatureTable.OpenAsync(fl);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;if (_sft.OutFields == null)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _sft.OutFields = new Esri.ArcGISRuntime.Tasks.Query.OutFields();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;foreach (FieldInfo fi in _sft.Schema.Fields)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _sft.OutFields.Add(fi.Name);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;//&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;// Do adds/updates/deletes&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;//&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;// Send changes to service&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;_sft.ApplyEditsAsync();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Nov 2015 15:59:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/servicefeaturetable-not-properly-initialized/m-p/403895#M4805</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2015-11-12T15:59:08Z</dc:date>
    </item>
  </channel>
</rss>

