score:7

Accepted answer

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;

Related Query

More Query from same tag