score:-2
you need to optimize your db, take a look on index
you can also do the same request with specification pattern
public class namedpersonspecification : abstractspecification<person>
{
private string _name;
public namedpersonspecification(string name)
{
this._name= name;
}
public override bool issatisfiedby(person o)
{
return o.name.equals(_name);
}
}
and query like this:
iqueryable<t>.where(specification.issatisfiedby)
the advantage is to be more clear to request your linq
score:2
the problem here isn't with what linq is actually doing. the query for scenario 2 would just create something similar to:
select * from
person
where department = n'development'
and gender = n'male'
and role = n'manager'
you need to run this against the database directly to figure out what's your performance bottleneck. you're most likely missing indexes and therefore forcing your database server to scan the entire table to get the result set back.
if you're using sql server, try running a profiler to determine the exact query that (assuming) linq-to-ef is generating and tune that.
Source: stackoverflow.com
Related Query
- How to construct efficient queries in C# LINQ to filter data
- How does linq actually execute the code to retrieve data from the data source?
- How to create an efficient data structure for two-dimensional LINQ operations?
- C# LINQ How to get a data source from a db?
- How to filter distinct data using linq
- How to swap the data source associated with a Linq query?
- How to filter data using Linq in List<object>
- How to filter related data using Entity Framework and LINQ to SQL and LinqKit PredicateBuilder Or IdeaBlade DevForce
- LINQ how to Filter the data based on the value of the properties
- how to select data by linq in many-to-many relationship in First code Entity framework 5
- How to reinsert data from one table onto itself using LINQ in code migration?
- How to Filter data based on two property in linq
- How to keep string data for having best performance when selecting string list via LINQ by StartsWith and EndsWith queries
- Simple linq question: How to filter a source afterwards?
- C# LINQ or for loop How to get a data source from a db?
- How to filter data using ternary operator in linq
- c# Linq or code to extract groups from a single list of source data
- how to fetch data from database using linq query for relationship 1:N and N:N (between 3 entity) in asp.net mvc EF code first?
- C# Linq How do I filter a list with the data of an object and store the result in another list?
- How to join two linq queries to find some common data between them
- Linq - how to filter dataset based on data in another table?
- How Filter Binding Source Connected To linq Query
- How do I construct a LINQ (EF) query to project pages of data
- How can I filter a dictionary using LINQ and return it to a dictionary from the same type
- How are people unit testing code that uses Linq to SQL
- How do you construct a LINQ to Entities query to load child objects directly, instead of calling a Reference property or Load()
- How I can filter a dataTable with Linq to datatable?
- How to bind LINQ data to dropdownlist
- How to eager load sibling data using LINQ to SQL?
- Linq To Entities - how to filter on child entities
More Query from same tag
- How to Convert Anonymous Type to List <dynamic> using Linq to SQL in C#
- Using AND in JOIN in LINQ
- asp.net mvc LINQ Finding out if any children or grandchildren exist with the current controller and Action
- Case insensitive string compare with linq-to-sql and linq-to-objects
- Default Empty in LINQ not functioned so i need to find what is the problem
- Can not get data after compare two tables
- How to Cancel a PLINQ Query in a WinForms Application
- Linq query returns duplicate results
- linq query to return nested list for unique items
- KeyPairValue Linq how to set value
- LINQ query showing different results
- Left Join on Linq query when also using the Where clause on joint table
- How to write a LINQ query resulting in a Dictionary?
- Cumulative sum of stock movements when dates and id is not in the same order
- C# XElement: Node Formatting with HTML
- out variables in a linq statement
- how to pass two variables value using linq
- Creating dynamic queries with entity framework
- Anonymous type select object and its children
- How to get only odd arguments
- Entity Framework + Linq LEFT JOIN using a where clause?
- Distinct count with group fails though count is working fine
- Sort a GridView thats bound to a Linq query
- Property Sum translated to sql on IQueryable with linq to entities
- How to generate previous months orders from db using linq or lambda?
- sorting the list and showing list in grid
- how to read XmlDocument by maximumn attribute to minimum attribute?
- Linq Query Formatting in Visual Studio
- GroupBy with after projection to domain model without .ToList()
- What would this sql query (w count and group by) look like when translated to linq?