This question is locked. New answers and comments are not allowed.
Hello, I have big problem with OQL query in OpenAccessDomainService.
I have application with Silverlight client and RIA Web Service (OpenAccessDomainService), and I need to implement lazy loading approach.
For example I created method getAnimalsLazy(string stringQuery, int range, int page) where I can pass stringQuery from filters, records per page and page. This methods works fine but is dramatically slow.
To compare it I created method getAnimals() which is so fast, it is loading 15 000 records in ~4 sec. When I run getAnimalsLazy it is loading 25 records in ~2 sec.
I don't know what I am doing wrong, could somebody help me.
This is example code:
01.[EnableClientAccess()]02.public partial class ZooDomainService : OpenAccessDomainService<Model.ZooDomainModel>03.{04. public ZooDomainService() : base()05. {06. }07. 08. 09. /// <param name="stringQuery">eg. AND (r.type = "Elephant" OR r.type = "Monkey") ORDER BY r.id ASC</param>10. public IQueryable<Animals> getAnimalsLazy(string stringQuery, int range, int page)11. {12. stringQuery = "SELECT r FROM AnimalsExtent AS r WHERE true " + stringQuery;13. 14. Database db = Database.Get("Connection");15. IObjectScope scope = db.GetObjectScope();16. Query<Animals> qry = scope.GetOqlQuery<Animals>(stringQuery);17. 18. int toSkip = (page - 1) * range;19. qry.Skip = toSkip;20. qry.MaxResultCount = range;21. 22. return qry.ExecuteEnumerable().AsQueryable<Animals>();23. }24. 25. public IQueryable<Animals> getAnimals()26. {27. return this.DataContext.Animals;28. }29.}