Walaa wrote:
Could you please explain in details, what performance problems are you facing?
var query = (from pd in ProductDepartmentEntity.Query
join p in ProductEntity.Query on pd.ProductDescriptionId equals p.ProductDescriptionId
join pdd in ProductDescriptionEntity.Query on pd.ProductDescriptionId equals pdd.Id
where
pd.DepartmentId == departmentId &&
pdd.IsValid == true &&
p.IsValid == true &&
(p.Stock > pdd.CriticalStock || pdd.IsAlwaysOnShow)
select pdd);
FilterQuery = query;
var firstSpecList = (from pl in FilterQuery
join p in ProductEntity.Query on pl.Id equals p.ProductDescriptionId
join s in SpecialityItemEntity.Query on p.SpecialityItemFirstId equals s.Id
where (p.Stock > p.ProductDescription.CriticalStock || p.ProductDescription.IsAlwaysOnShow)
&& p.IsValid == true && p.ProductDescription.IsValid == true
group s by new { PDId = pl.Id, s.Id, s.Name, s.OrderNumber } into g
select g.Key).GroupBy(s => new { s.Id, s.Name, s.OrderNumber })
.OrderBy(v => v.Key.OrderNumber).Select(vi => new { vi.Key, Count = vi.Count() }).ToList();
I have a query like this, I call this query several times and this makes my system very slow, I need to cache this query, I should be able to parameterize this, so it will not make my CPU tired.
Thanks.