mercredi 20 janvier 2016

Performance Issue While Fecthing the Record and Displaying in Grid?

Actually i am fetching the records from two table One is VehicleDetails and other one is Barcodedetails. 1)Vehicle Details Contains 10,000 records and Barcode Details Contains 11Lakhs records and Each vehicle is Mapped to a specific Bardcode.

currently what iam doing is first iam getting all the BarcodeDetails from BarcodeDetailsTable and its take 8sec's to complete it,

   List<VTSBarCodeDetail> barCodeDetailMaster = barCodeDetailRepository.Get(null, null) as List<VTSBarCodeDetail>;

then i will get the Vehicle Details

 List<VTSVehicleRegistrationObject> vehicleRegObject = (Some  Simple query to get the VehicleRegobject)

and then i am running a for loop in this for loop iam 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.

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

Aucun commentaire:

Enregistrer un commentaire