Linq-to-SQL partial loading of association

134 views Asked by At

I have XCore and XEvent associated tables (XCore.Id => XEvent.CoreId). XCore table has few rows and XEvent has more than 163000 of rows. Inside of XCore methods I want to write (for example):

XEvent[] events = this.XEvents.Where(e => e.Id > 150000).ToArray();

SQL Profiler shows that when I touch XEvents property in first time, Linq-to-SQL loads ALL 163000 of rows, and then executes LINQ methods on client side. Is it possible to force execution of Where to database side and do not load millions of rows I do not need?

0

There are 0 answers