This question is locked. New answers and comments are not allowed.
As my application grows, lazy loading will start to become a performance hit so I'm looking into selectively eager loading some of the data. I'm familiar with the fetch plan API, and have implemented that in certain sections of the code. However, I would like to be able to filter the child objects in the query.
For example, I have Post table and a Comment table which are related (a post can have many comments). Currently I can get a list of posts and all of their comments via fetch plans, but I would like to be able to apply a filter (lambda expression) to specify which comments I want loaded with the posts. (i.e. I just want to display the top 10 comments first, and then load the rest via ajax if the user wants).
I was given a couple solutions in reply to my comment here:
"The first option is to create 2 LINQ statements - the first one retrieving the needed post(s) and the second one getting the comments with additional filtering. The second option is to filter both in a single LINQ statement with a join."
The first option is more scalable than lazy loading, but would effectively boil down to a "where comment_id in (*list of post ids*)" query which would fail for a very large amount of posts. The second option is great, but can I map that LINQ join query to OpenAccess domain classes?
Thanks for any help, I'm really liking OpenAccess so far. This is the only thing I'm having trouble working around cleanly.
For example, I have Post table and a Comment table which are related (a post can have many comments). Currently I can get a list of posts and all of their comments via fetch plans, but I would like to be able to apply a filter (lambda expression) to specify which comments I want loaded with the posts. (i.e. I just want to display the top 10 comments first, and then load the rest via ajax if the user wants).
I was given a couple solutions in reply to my comment here:
"The first option is to create 2 LINQ statements - the first one retrieving the needed post(s) and the second one getting the comments with additional filtering. The second option is to filter both in a single LINQ statement with a join."
The first option is more scalable than lazy loading, but would effectively boil down to a "where comment_id in (*list of post ids*)" query which would fail for a very large amount of posts. The second option is great, but can I map that LINQ join query to OpenAccess domain classes?
Thanks for any help, I'm really liking OpenAccess so far. This is the only thing I'm having trouble working around cleanly.