# Binding data to FeatureSource

**URL:** <https://community.thinkgeo.com/t/binding-data-to-featuresource/5946>\
**Category:** WebForms\
**Created:** [September 23, 2011, 7:20am UTC](https://community.thinkgeo.com/t/binding-data-to-featuresource/5946 "2011-09-23T07:20:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Revathy](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/9de0a6/32.png) [@Revathy](https://community.thinkgeo.com/u/Revathy)\
**Post date:** [September 23, 2011, 7:20am UTC](https://community.thinkgeo.com/t/binding-data-to-featuresource/5946/1 "2011-09-23T07:20:21Z")

</div>

Hi,

Iam&nbsp;binding&nbsp;the&nbsp;data&nbsp;to&nbsp;FeatureSource&nbsp;of&nbsp;InMemorymarkeroverlay&nbsp;by&nbsp;using&nbsp;For&nbsp;Loop&nbsp;as&nbsp;below.&nbsp;It&nbsp;worksfine.&nbsp;But&nbsp;it&nbsp;is&nbsp;time&nbsp;consuming&nbsp;if&nbsp;the&nbsp;number&nbsp;of&nbsp;markers&nbsp;increases.&nbsp;Is&nbsp;there&nbsp;any&nbsp;possible&nbsp;option&nbsp;to&nbsp;load&nbsp;the&nbsp;FeatureSource&nbsp;without&nbsp;using&nbsp;For&nbsp;Loop/ForEach..&nbsp;Loop?

``

``

`

memoryFeatureLayer.FeatureSource.Open();

memoryFeatureLayer.FeatureSource.BeginTransaction();

 

for (var i = 0; i < 20; i++)Random random = new Random(i.GetHashCode());Vertex v = new Vertex(-95.28109 + random.Next(1, 10), 38.95363 + random.Next(1, 5));Feature feature = new Feature(v, i.ToString());"AssetType", "Endpoint");Feature feature1 = new Feature(-118.28109, 34.505363);"AssetType", "Meter");"LA", feature1);FeatureSourceColumn column = new FeatureSourceColumn("AssetType");
`

{

&nbsp;

&nbsp;

&nbsp;

feature.ColumnValues.Add(

memoryFeatureLayer.InternalFeatures.Add(i.ToString(),&nbsp;feature);

}

&nbsp;

feature1.ColumnValues.Add(

memoryFeatureLayer.InternalFeatures.Add(

&nbsp;

memoryFeatureLayer.Columns.Add(column);

memoryFeatureLayer.FeatureSource.CommitTransaction();

memoryFeatureLayer.FeatureSource.Close();

---

<div class="post-metadata">

**Author:** ![Revathy](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/9de0a6/32.png) [@Revathy](https://community.thinkgeo.com/u/Revathy)\
**Post date:** [September 23, 2011, 7:22am UTC](https://community.thinkgeo.com/t/binding-data-to-featuresource/5946/2 "2011-09-23T07:22:10Z")

</div>

Sorry&nbsp;the&nbsp;code&nbsp;is&nbsp;not&nbsp;binded&nbsp;properly.&nbsp;  
&nbsp;&nbsp;  
&nbsp;`memoryFeatureLayer.FeatureSource.Open(); memoryFeatureLayer.FeatureSource.BeginTransaction();for (var i = 0; i < 20; i++)            {                Random random = new Random(i.GetHashCode());                Vertex v = new Vertex(-95.28109 + random.Next(1, 10), 38.95363 + random.Next(1, 5));                Feature feature = new Feature(v, i.ToString());                feature.ColumnValues.Add("AssetType", "Endpoint");                memoryFeatureLayer.InternalFeatures.Add(i.ToString(), feature);            }            Feature feature1 = new Feature(-118.28109, 34.505363);            feature1.ColumnValues.Add("AssetType", "Meter");            memoryFeatureLayer.InternalFeatures.Add("LA", feature1);            FeatureSourceColumn column = new FeatureSourceColumn("AssetType");            memoryFeatureLayer.Columns.Add(column);            memoryFeatureLayer.FeatureSource.CommitTransaction();            memoryFeatureLayer.FeatureSource.Close(); `

---

<div class="post-metadata">

**Author:** ![Ethan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ethan/32/19964_2.png) [@Ethan](https://community.thinkgeo.com/u/Ethan)\
**Post date:** [September 26, 2011, 11:14am UTC](https://community.thinkgeo.com/t/binding-data-to-featuresource/5946/3 "2011-09-26T11:14:02Z")

</div>

Hi&nbsp;Revathy,&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;did&nbsp;a&nbsp;test&nbsp;like&nbsp;this:&nbsp;  
&nbsp;&nbsp;  
&nbsp;` InMemoryMarkerOverlay overlay = new InMemoryMarkerOverlay();                Stopwatch sw = new Stopwatch();                sw.Start();                for (var i = 0; i < 20000; i++)                {                    Random random = new Random(i.GetHashCode());                    Vertex v = new Vertex(-95.28109 + random.Next(1, 10), 38.95363 + random.Next(1, 5));                    Feature feature = new Feature(v, i.ToString());                    feature.ColumnValues.Add(“AssetType”, “Endpoint”);                    overlay.Features.Add(i.ToString(), feature);                }                sw.Stop();`&nbsp;  
&nbsp;&nbsp;  
&nbsp;It&nbsp;only&nbsp;takes&nbsp;about&nbsp;181&nbsp;milliseconds.&nbsp;I&nbsp;think&nbsp;this&nbsp;time&nbsp;shouldn’t&nbsp;unacceptable.&nbsp;  
&nbsp;&nbsp;  
&nbsp;How&nbsp;did&nbsp;you&nbsp;get&nbsp;data&nbsp;from&nbsp;datasource?&nbsp;If&nbsp;your&nbsp;datasource&nbsp;is&nbsp;in&nbsp;disk,&nbsp;could&nbsp;you&nbsp;try&nbsp;to&nbsp;load&nbsp;them&nbsp;to&nbsp;memory&nbsp;in&nbsp;one&nbsp;time,&nbsp;and&nbsp;then&nbsp;separate&nbsp;them&nbsp;to&nbsp;many&nbsp;records,&nbsp;then&nbsp;loop&nbsp;in&nbsp;memory&nbsp;and&nbsp;add&nbsp;them&nbsp;to&nbsp;our&nbsp;layer?&nbsp;  
&nbsp;&nbsp;  
&nbsp;If&nbsp;in&nbsp;your&nbsp;loop&nbsp;you&nbsp;need&nbsp;read&nbsp;from&nbsp;disk&nbsp;each&nbsp;time,&nbsp;that&nbsp;should&nbsp;very&nbsp;slow.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Don

---

<div class="post-metadata">

**Author:** ![Revathy](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/9de0a6/32.png) [@Revathy](https://community.thinkgeo.com/u/Revathy)\
**Post date:** [November 21, 2011, 10:51pm UTC](https://community.thinkgeo.com/t/binding-data-to-featuresource/5946/4 "2011-11-21T22:51:19Z")

</div>

I&nbsp;need&nbsp;to&nbsp;bind&nbsp;data&nbsp;from&nbsp;datatable&nbsp;with&nbsp;50,000&nbsp;markers&nbsp;to&nbsp;FeatureSource&nbsp;of&nbsp;InMemoryMarkerOverlay.&nbsp;My&nbsp;datatable&nbsp;size&nbsp;may&nbsp;increase&nbsp;upto&nbsp;1&nbsp;lakh&nbsp;records.&nbsp;While&nbsp;using&nbsp;For..Loop&nbsp;to&nbsp;bind&nbsp;these&nbsp;datas&nbsp;to&nbsp;FeatureSource&nbsp;of&nbsp;the&nbsp;InMemoryMarkerOverlay&nbsp;it&nbsp;takes&nbsp;around&nbsp;4secs&nbsp;which&nbsp;is&nbsp;not&nbsp;acceptable.&nbsp;Can&nbsp;you&nbsp;please&nbsp;get&nbsp;a&nbsp;solution&nbsp;to&nbsp;bind&nbsp;bulk&nbsp;data&nbsp;to&nbsp;FeatureSource?

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [November 22, 2011, 12:19pm UTC](https://community.thinkgeo.com/t/binding-data-to-featuresource/5946/5 "2011-11-22T12:19:19Z")

</div>

Hello&nbsp;Revathy,&nbsp;  
  
  
  
Thanks&nbsp;for&nbsp;your&nbsp;further&nbsp;information.&nbsp;  
  
  
  
Have&nbsp;you&nbsp;tried&nbsp;the&nbsp;way&nbsp;Don&nbsp;said&nbsp;before?&nbsp;I&nbsp;think&nbsp;if&nbsp;every&nbsp;loop&nbsp;you&nbsp;will&nbsp;search&nbsp;the&nbsp;database,&nbsp;that&nbsp;will&nbsp;great&nbsp;decrease&nbsp;the&nbsp;speed,&nbsp;try&nbsp;to&nbsp;get&nbsp;them&nbsp;all&nbsp;from&nbsp;the&nbsp;beginning&nbsp;will&nbsp;be&nbsp;helpful.

Or&nbsp;could&nbsp;you&nbsp;please&nbsp;provide&nbsp;some&nbsp;code&nbsp;which&nbsp;you&nbsp;get&nbsp;the&nbsp;data?&nbsp;it&nbsp;will&nbsp;be&nbsp;helpful&nbsp;to&nbsp;find&nbsp;the&nbsp;root&nbsp;cause.  
  
  
  
Regards,&nbsp;  
  
  
  
Gary
