Skip to content

Repository files navigation

This project is to demonstrate how to use a temporary table to achive large volume batch loading in efcore.

With the temp table, it's easier and faster to load items by ids.

When the ids are less than the threshold (currently set to 20), it uses the normal .Where(x=> ids.Contains(x.Id)) to load. When the ids are above the threshold, it uses the temp table + join to load.

//Load by .Contains(x.id)varitems=awaitcontext.LoadByIds(context.Items,Enumerable.Range(1,5), x =>x.Id);//Load by temp table + joinitems=awaitcontext.LoadByIds(context.Items,Enumerable.Range(1,30), x =>x.Id);//Reuse temp tableusing(vartmpTable=context.CreateTempIdTable()){tmpTable.AddIds(Enumerable.Range(1,100));items=awaittmpTable.Filter(context.Items, x =>x.Id).ToListAsync();items=awaittmpTable.Filter(context.Items, x =>x.Id).ToListAsync();items=awaittmpTable.TempIdTable.Join(context.Items, x =>x.RefId, y=>y.Id,(x,y)=>y).ToListAsync();}

About

No description, website, or topics provided.

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages