score:7
the reason is that for each record you are retrieving it's countries which for 200k records multiplies into alot of records.
are you going to querying this data later to reduce it to your specific needs? if so don't .tolist()
them just yet.
change your repository methods to return iqueryable
, that way you can restrict the query to the particular data you require later down the line reducing the ammount of data you put into memeory
private entities _context;
public pointsrepository(entities context)
{
_context = context
}
public iqueryable<pointstable> getall()
{
return context.points_table;
}
public iqueryable<pointstable> getallcomplete()
{
return context.points_table.include("countries");
}
you can then add your specific filters and tolist
the smaller result. e.g.
using (entities context = new entities())
{
var rep = new pointsrepository(context);
// this will change the query you send to sql to only
// retrieve the specific data you want and should result
// in much quicker execution
var result = rep.getallcomplete() // get all with includes
.where(p => p.property = "specific") // refine the query
.tolist() // retrieve the data and add to memory
}
hope this helps
score:0
as parallel(), not working with linq to entities, working only with linq to object.
load 200k with ef not is good plain.
you can improve performance with the readonly load:
context.points_table.mergeoption = mergeoption.notracking;
Source: stackoverflow.com
Related Query
- Why is Entity Framework .ToList() with .Include very slow and how can I speed it up?
- Can I limit how many levels the .include adds with LINQ and Entity Framework 5?
- How can I convert Sql query to Linq and its equivalent with Join() method in Entity Framework Core
- How can I get only records with a unique property using entity framework and linq?
- How to avoid memory overflow when querying large datasets with Entity Framework and LINQ
- How can I extract a list of Tuple from a specific table with Entity Framework / LINQ?
- How can i write SQL update query with where clause in Entity Framework in C#
- How can I use Entity Framework on an object graph past a depth of 2 with MySQL Connector / NET?
- How to include sorted navigation properties with Entity Framework
- C# Entity Framework + Linq - how do you speed up a slow query?
- How to map Integer to String with AutoMapper 3 and Entity Framework
- How to query many-to-many relationship with 'AND' condition using LINQ and Entity Framework
- How to get a count of records with entity framework and repository pattern
- How can I query using Entity Framework with an alpha-numeric comparison?
- Entity Framework with LINQ using CONTAINS in WHERE clause very slow with large integer list
- Can I load hierarchical data with Entity Framework 4 using ".Include" and filter a Navigation Property based on some criteria
- How can I speed up my Entity Framework LINQ Query?
- In Entity Framework Core, how can I query data on joined tables with a condition at DB level (not local LINQ)?
- How can you force Entity Framework to use string instead of char for CHAR, NCHAR, VARCHAR(1) and NVARCHAR(1) columns?
- How to calculate STD dev and Average with linq and entity framework at the same time
- How to convert a SQL with multiple left joins to an Entity Framework LINQ statement using Include methods (No Join methods)?
- Entity Framework : joining dbcontext table with a List makes retrieval very slow slow
- How to Lazy Load child object with string primary key in Entity Framework Code First?
- How can I get data from the Entity Framework if I only know the table name and the column name from which to get the data?
- How to translate a query with an EntityState and a value from Entity Framework 5 to 6?
- how to execute a nested group aggregate functions with multi groupBy columns using entity framework and linq?
- How do i obtain foreign table field using string value for fieldname with reflection and entity framework
- How can I generate this query with Entity Framework to return the corresponding collections?
- How to select a query with multiple columns and put it into variables using Entity Framework and ASP.NET?
- How to get first row from DB using Entity Framework where column starts with certain string and continues with numeric characters
More Query from same tag
- Count the number of Records in Child in MVC
- In which cases do I need to create two different extension methods for IEnumerable and IQueryable?
- What is wrong with this dynamic dropdownlist?
- Split and then Joining the String step by step - C# Linq
- LINQ - Sorting by using OrderBy on a nullable field
- "Object reference not set to an instance of an object" even when I checked null
- How can I use Distinct on a specific property and select the object to keep based on a predicate?
- INNER Join and LEFT OUTER JOIN in EF-Core with Linq
- LINQ - Removing items in a List<T> that contain one item of an Array in any order or position
- Getting attributes from xml using Linq
- To .Take() or not to .Take(), that is the question
- Error comparing guid to guid in linq
- What is the difference between IQueryable<T> and IEnumerable<T>?
- Initialize a Jagged Array the LINQ Way
- C# dynamic table creation : display table data in aspx page using linq query in a wcf service
- LINQ Replace DBNull with Blank String
- Is it possible to make 1 generic method out of these 2 linq statements?
- Get Object reference not set to an instance of an object. Error from Linq
- Is there a way to speed up the contains extension in a LINQ query for large datasets?
- Too many outer joins in LINQtoSQL generated SQL
- LINQ to Entities does not recognize the method 'System.String get_Item(Int32)' method, and this method cannot be translated into a store expression
- linq to nhibernate compareto not supported
- How to dynamically add .Where() clause in LINQ
- What is the most efficient Linq statement to query these tables?
- Selection from List of tuple to List of objects C#
- How to Load type from string directly into linq expression in C#?
- How to return a List(Of String) from a LINQ statement with a Group By in VB.net?
- linq equals override
- Convert text file to List<int>
- Unable to convert string to int in LINQ query from MongoDB