Performance of Linq on entity framework vs SQL stored procedure

c# entity-framework linq performance

Question

To retrieve certain data, we are employing the Entity Framework. The code below illustrates how the LINQ query makes use of several joins. This should be changed to a SQL Stored Procedure, as it is faster, I was told. Why is this LINQ code slow, and how can I make it faster?

var brands = (from b in entity.tblBrands
                          join m in entity.tblMaterials on b.BrandID equals m.BrandID
                          join bm in entity.tblBranchMaterials on m.MaterialID equals bm.MaterialID
                          join br in entity.tblBranches on bm.BranchID equals br.BranchID
                          where br.BranchID == branch.branchId
                          select new Brand { brandId=b.BrandID, brandName=b.BrandName, SAPBrandId=b.SAPBrandID}).Distinct();
            return brands.ToList();
1
3
3/6/2013 7:55:22 AM

Popular Answer

ZZZ_tmp
5
3/6/2013 8:12:15 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow