# Can't query InMemoryFeatureLayer

**URL:** <https://community.thinkgeo.com/t/cant-query-inmemoryfeaturelayer/2291>\
**Category:** WinForms\
**Created:** [September 3, 2013, 11:18am UTC](https://community.thinkgeo.com/t/cant-query-inmemoryfeaturelayer/2291 "2013-09-03T11:18:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert4](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/46a35a/32.png) [@Robert4](https://community.thinkgeo.com/u/Robert4)\
**Post date:** [September 3, 2013, 11:18am UTC](https://community.thinkgeo.com/t/cant-query-inmemoryfeaturelayer/2291/1 "2013-09-03T11:18:38Z")

</div>

Hi&nbsp;-&nbsp;I&nbsp;am&nbsp;creating&nbsp;InMemoryFeatureLayers&nbsp;on&nbsp;the&nbsp;fly&nbsp;and&nbsp;showing&nbsp;them&nbsp;in&nbsp;the&nbsp;WinformsMap.&nbsp;The&nbsp;arrays&nbsp;adEasting,&nbsp;adNorthing,&nbsp;and&nbsp;adSampledValue&nbsp;contain&nbsp;the&nbsp;point&nbsp;information&nbsp;I&nbsp;want&nbsp;to&nbsp;use.&nbsp;  
  
  
  
Everything&nbsp;is&nbsp;going&nbsp;well&nbsp;until&nbsp;I&nbsp;try&nbsp;to&nbsp;query&nbsp;the&nbsp;layer&nbsp;to&nbsp;place&nbsp;field&nbsp;values&nbsp;in&nbsp;a&nbsp;table.&nbsp;My&nbsp;code&nbsp;is&nbsp;below.&nbsp;Why&nbsp;is&nbsp;omg.FeatureSource.CanExecuteSqlQuery&nbsp;false?&nbsp;  
  
  
  
Dim&nbsp;lFeature&nbsp;As&nbsp;New&nbsp;ThinkGeo.MapSuite.Core.Feature  
  
  
  
Dim&nbsp;fscID&nbsp;As&nbsp;New&nbsp;FeatureSourceColumn("ID",&nbsp;"Integer",&nbsp;30)  
  
Dim&nbsp;fscValue&nbsp;As&nbsp;New&nbsp;FeatureSourceColumn("Value",&nbsp;"Double",&nbsp;30)  
  
Dim&nbsp;fscEasting&nbsp;As&nbsp;New&nbsp;FeatureSourceColumn("Easting",&nbsp;"Double",&nbsp;30)  
Dim&nbsp;fscNorthing&nbsp;As&nbsp;New&nbsp;FeatureSourceColumn("Northing",&nbsp;"Double",&nbsp;30)  
  
  
  
Dim&nbsp;lFeatureSourceColumn&nbsp;As&nbsp;New&nbsp;List(Of&nbsp;FeatureSourceColumn)  
  
  
  
lFeatureSourceColumn.Add(fscID)  
lFeatureSourceColumn.Add(fscValue)  
lFeatureSourceColumn.Add(fscEasting)  
lFeatureSourceColumn.Add(fscNorthing)  
  
  
  
Dim&nbsp;lCollectionOfFeatureSourceColumns&nbsp;As&nbsp;New&nbsp;System.Collections.ObjectModel.Collection(Of&nbsp;FeatureSourceColumn)  
  
  
  
lCollectionOfFeatureSourceColumns.Add(fscID)  
lCollectionOfFeatureSourceColumns.Add(fscValue)  
lCollectionOfFeatureSourceColumns.Add(fscEasting)  
lCollectionOfFeatureSourceColumns.Add(fscNorthing)  
  
  
  
Dim&nbsp;cc&nbsp;As&nbsp;System.Collections.Generic.IEnumerable(Of&nbsp;FeatureSourceColumn)&nbsp;=&nbsp;lFeatureSourceColumn.AsEnumerable  
  
  
  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim&nbsp;lFeatureList&nbsp;As&nbsp;New&nbsp;List(Of&nbsp;Feature)  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;For&nbsp;i&nbsp;=&nbsp;0&nbsp;To&nbsp;adEasting.GetUpperBound(0)  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim&nbsp;c&nbsp;As&nbsp;New&nbsp;System.Collections.ObjectModel.Collection(Of&nbsp;String)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c.Add("ID:"&nbsp;&&nbsp;i)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c.Add("Value:"&nbsp;&&nbsp;adSampledValue(i))  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c.Add("Easting:"&nbsp;&&nbsp;adEasting(i))  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c.Add("Northing:"&nbsp;&&nbsp;adNorthing(i))  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lFeature&nbsp;=&nbsp;New&nbsp;ThinkGeo.MapSuite.Core.Feature(adEasting(i),&nbsp;adNorthing(i),&nbsp;Str(i),&nbsp;c)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lFeatureList.Add(lFeature)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Next&nbsp;i  
  
  
  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim&nbsp;lfeaturelist&nbsp;As&nbsp;System.Collections.Generic.IEnumerable(Of&nbsp;Feature)&nbsp;=&nbsp;lFeatureList.AsEnumerable  
  
  
  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim&nbsp;omg&nbsp;As&nbsp;New&nbsp;InMemoryFeatureLayer(cc,&nbsp;lfeaturelist)  
  
  
  
Does&nbsp;anyone&nbsp;have&nbsp;an&nbsp;idea?&nbsp;A&nbsp;better&nbsp;suggestion&nbsp;to&nbsp;accomplish&nbsp;this?&nbsp;Thanks&nbsp;in&nbsp;advance&nbsp;for&nbsp;any&nbsp;advice.

---

<div class="post-metadata">

**Author:** ![Robert4](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/46a35a/32.png) [@Robert4](https://community.thinkgeo.com/u/Robert4)\
**Post date:** [September 3, 2013, 11:25am UTC](https://community.thinkgeo.com/t/cant-query-inmemoryfeaturelayer/2291/2 "2013-09-03T11:25:05Z")

</div>

so&nbsp;sorry&nbsp;the&nbsp;last&nbsp;two&nbsp;lines&nbsp;should&nbsp;read&nbsp;  
&nbsp;&nbsp;  
&nbsp;Dim&nbsp;lfeaturelistenumerable&nbsp;As&nbsp;System.Collections.Generic.IEnumerable(Of&nbsp;Feature)&nbsp;=&nbsp;lFeatureList.AsEnumerable&nbsp;  
&nbsp;Dim&nbsp;omg&nbsp;As&nbsp;New&nbsp;InMemoryFeatureLayer(cc,&nbsp;lfeaturelistenumerable)&nbsp;

---

<div class="post-metadata">

**Author:** ![Summer1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@Summer1](https://community.thinkgeo.com/u/Summer1)\
**Post date:** [September 3, 2013, 11:55pm UTC](https://community.thinkgeo.com/t/cant-query-inmemoryfeaturelayer/2291/3 "2013-09-03T23:55:24Z")

</div>

Hi&nbsp;Robert,&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;ticket,&nbsp;I&nbsp;am&nbsp;sorry&nbsp;to&nbsp;say&nbsp;that&nbsp;InMemoryFeatureLayer&nbsp;doesn’t&nbsp;support&nbsp;“ExecuteSqlQuery”,&nbsp;but&nbsp;a&nbsp;walk&nbsp;around&nbsp;could&nbsp;be&nbsp;to&nbsp;use&nbsp;linq&nbsp;with&nbsp;following&nbsp;code:&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;using&nbsp;System.Linq;&nbsp;  
&nbsp;…&nbsp;  
&nbsp;private&nbsp;void&nbsp;DisplayMap\_Load(object&nbsp;sender,&nbsp;EventArgs&nbsp;e)&nbsp;  
&nbsp;{&nbsp;  
&nbsp;…&nbsp;  
&nbsp;Feature&nbsp;feature1&nbsp;=&nbsp;new&nbsp;Feature(0,&nbsp;0);&nbsp;  
&nbsp;Feature&nbsp;feature2&nbsp;=&nbsp;new&nbsp;Feature(10,&nbsp;10);&nbsp;  
&nbsp;feature1.ColumnValues.Add(“id”,&nbsp;“1”);&nbsp;  
&nbsp;feature2.ColumnValues.Add(“id”,&nbsp;“2”);&nbsp;  
&nbsp;&nbsp;  
&nbsp;InMemoryFeatureLayer&nbsp;inm&nbsp;=&nbsp;new&nbsp;InMemoryFeatureLayer();&nbsp;  
&nbsp;inm.Open();&nbsp;  
&nbsp;inm.Columns.Add(new&nbsp;FeatureSourceColumn(“id”));&nbsp;  
&nbsp;inm.InternalFeatures.Add(feature1);&nbsp;  
&nbsp;inm.InternalFeatures.Add(feature2);&nbsp;  
&nbsp;&nbsp;  
&nbsp;IEnumerable\<Feature\>&nbsp;features=inm.InternalFeatures.Where\<Feature\>(f=\>f.ColumnValues[“id”]==“1”);&nbsp;  
&nbsp;List\<Feature\>&nbsp;fes&nbsp;=&nbsp;new&nbsp;List\<Feature\>(features);&nbsp;  
&nbsp;…&nbsp;&nbsp;  
&nbsp;}&nbsp;  
&nbsp;&nbsp;  
&nbsp;if&nbsp;you&nbsp;have&nbsp;any&nbsp;more&nbsp;question&nbsp;,&nbsp;please&nbsp;feel&nbsp;free&nbsp;to&nbsp;let&nbsp;us&nbsp;know.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Best&nbsp;Regards&nbsp;  
&nbsp;&nbsp;  
&nbsp;Summer
