This question is locked. New answers and comments are not allowed.
I'm using the recommended configuration for virtual loading:
var context = new myContext(); var query = context.GetmyQuery().OrderBy(o => o.ID); query.IncludeTotalCount = true; var view = new VirtualQueryableCollectionView() { LoadSize = 10, VirtualItemCount = 100 }; view.ItemsLoading += (s, e) => { context.Load<myData>(query.Skip(e.StartIndex).Take(e.ItemCount)).Completed += (sender, args) => { var lo = (LoadOperation)sender; if (lo.TotalEntityCount != -1 && lo.TotalEntityCount != view.VirtualItemCount) { view.VirtualItemCount = lo.TotalEntityCount; } view.Load(e.StartIndex, lo.Entities); }; }; DataContext = view;Using the SQL profiler I see some mysterious behaviour:
- A call to SQL is made to get the total count of objects
- A call to SQL is made to retrieve the 10 first objects.
- Nothing happens for 3 seconds (not on screen and not in the SQL contact)
- A call to SQL is made to get the total count of objects.
- A call to SQL is made to get the 10 first(!) objects.
- The Grid is updated on screen.
- A call to SQL is made to get the total count of objects
- A call to SQL is made to get objects 11-20
- A call to SQL is made to get the total count of objects.
- A call to SQL is made to get objets 11-20
- ...and so on...
This rases three questions (at least...)
- Why is everything paused in 3 seconds after the initial SQL query?
- Why is every batch of 10 objects read twice from SQL ?
- Why is the total count of objects queried before every 10-object batch read?
(Using Q3 2010 SP1, EF4)
