Performance Issue While Fecthing the Record and Displaying in Grid?
<p>I am fetching the records from two table One is VehicleDetails and other one is Barcodedetails.</p>

<p>Vehicle Details Contains 10,000 records and Barcode Details Contains 1.1 million records and Each vehicle is Mapped to a specific Bardcode.</p>

<p>currently what I am doing is first is getting all the BarcodeDetails from BarcodeDetailsTable and its take 8 secs to complete it,</p>

<pre><code>List&lt;VTSBarCodeDetail&gt; barCodeDetailMaster = barCodeDetailRepository.Get(null, null) as List&lt;VTSBarCodeDetail&gt;;
</code></pre>

<p>then I will get the Vehicle Details </p>

<pre><code>List&lt;VTSVehicleRegistrationObject&gt; vehicleRegObject = (Some  Simple query to get the VehicleRegobject)
</code></pre>

<p>and then I am running a for loop in this for loop I am adding barcodeno passtype etc details to a list. this for loop is taking 1 min of time to complete it for 6k records.
here is my code and log file have a look at this.</p>

<pre><code>foreach (VTSVehicleRegistrationObject item in vehicleRegObject)
{
  barCodeDetails = barCodeDetailMaster.Where(x =&gt; x.VehicleId == Convert.ToInt32(item.VehicleId) &amp;&amp; x.BarCodeId == item.BarCodeId).FirstOrDefault();
  { 
  //some Logic add item to this list.
  }
</code></pre>