I am new to linq query my linq query shown below taking long time to execute,
List<InventoyModel> vehic = new List<InventoyModel>();
vehic = Winv.Select(x => new InventoyModel
{
InvID = x.Id,
WeaponBrand = WH.LKP_WeaponBrand.Where(b => b.BrandID == x.WeaponBrand).Select(b => b.BrandName).FirstOrDefault(),
LKP_WeaponBrand = x.WeaponBrand,
weaponModel = WH.LKP_WeaponModel.Where(m => m.ModelID == x.weaponModel).Select(b => b.ModelName).FirstOrDefault(),
LKP_WeaponModel = x.weaponModel,
WeaponType = WH.LKP_WeaponType.Where(b => b.TypeID == x.WeaponType).Select(b => b.WeaponName).FirstOrDefault(),
EntityCategoryID = x.EntityCategoryID,
// LKP_WeaponType=x.WeaponType,
SerialNo = x.Serial,
//LKP_WeaponSerial=x.Serial,
MadeOf = WH.LKP_BrandOrigin.Where(b => b.ID == x.MadeOf).Select(b => b.CountryName).FirstOrDefault(),
// LKP_BrandOrigin=Convert.ToInt32(x.MadeOf),
BulletCount = x.BuletCount,
AssignerCategoryID = x.AssignerCategoryID,
WeaponNote = x.Note,
EntityType = x.EntityType,
AssignedBy = x.AssignedBy,
EntityStatusName = WH.LKP_EntityStatus.Where(l => l.StatusID == x.EntityStatus).Select(l => l.Status).FirstOrDefault(),
IsFile = x.IsFile,
MarkazName = x.MarkazName,
MahafzaName = x.MahafzaName,
NID = x.EmpId.ToString().Trim(),
Datetime = x.Date,
UpdateDate = x.ModifyDate,
ModifierName = x.ModifyBy,
EntityQty = x.WeaponQty,
SCEntityQty = 0
}).ToList();
I know actually i am using many query inside query to get values creating problem but i dont know how to solve it.
Hopes for your suggestion
thanks
New contributor
Yasmeen Bibi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.