I'm new to Telerik OpenAccess.
I create Database-first approach with rlinq file and auto-generated classes. There are Master and Detail tables, which Master can have no Detail ID (DetailId column in Master can be NULL). pretty banal.
I want to get 5 records of Master-Detail hierarchical data through Json in ASP.NET MVC WebApi, so I write following code but it returns NullReferenceException
var fetchStrategy =
fetchStrategy.LoadWith<Master>(c => c.Detail); IQueryable<Master> entity = repository.GetAll().LoadWith(fetchStrategy)
.Where(m => m.DetailId !=
&& m.DetailId.Value == m.Detail.Id)
.OrderByDescending(m => m.GenerateTime)
I have two questions.
- What am I wrong in above code?
- I see `GetAll()` method perform `SELECT ... FROM Table` SQL query in order to fetch all records firstly, and then perform a query from them in program memory (checked by Telerik Data Access Profiler). is it right? Telerik autogenerated repository pattern file only expose GetAll and GetBy method (for single entity), so I try to use it.
The Telerik documentation is dataContext based only, so it is hard to do with new auto-generated repository pattern.