Hi I am using EF6 where I have large data to select from database where my query as follows:
var EntityInfo = _contextRegister.Entities.Where(x => x.IsDeleted != true).ToList();
foreach (var itm in EntityInfo)
{
Entity.Entity entity = new Entity.Entity();
entity.MainActivityId = itm.MainActivityId;
entity.SubGroupId = itm.SubGroupId;
entity.Id = Convert.ToInt32(itm.Id);
-------
entity.UAECityRegion = _contextFRAMEWORK.UAECityRegions.Where(m => m.Id == itm.UAECityRegionId).Select(m => m.RegionName).FirstOrDefault();
var voucherstautus = _contextRegister.EPayVoucherDatas.Where(m => m.EntityId == itm.Id).ToList();
foreach (var item in voucherstautus)
{
if (item.VoucherStatus == 10)
{
entity.PaymentStatus = Convert.ToInt32(item.VoucherStatus);
break;
}
}
entityList.Add(entity);
}
This query taking more than 10mins where how can I make this query better or should I use stored procedure instead of framework?