This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, I have got a user entity and a customer entity connected with a n:1 a association (many users belongs to one customer). When loading a user, I want also to load the customer. I set the "Eager Load Backreference" to true. when I now load a user via: var query = from
I see this SQL only: SELECT I didn't see any SQL for the customer entity and the customer object at the user entity is null (checked after the uow is closed, otherwise the customer will be loaded lazy). I checked the DB and the customer table is filled and the user table has a reference to the customer. What do I need to do, to get the eager loading to work? Kind regards, Sörnt |
|
|
I am confused. I created a simple test project with two entities, created a one to many relationship and set the "Eager Load Backreference" and the "Eager Load Collection" to true. For both navigation directions eager loading is working. I set "Eager Load Backreference" to and the "Eager Load Collection" to false and specified a value for the "Backreference Aggregates" and also for "Collection Aggregates". Also than, for both navigation directions eager loading is also working. I double checked the settings within my original project the associated object is not loaded via the "Eager Load Backreference" nor with the "Backreference Aggregates" settings. I thought setting the "Eager Load Backreference" will load the associated entity anyway. Any ideas? Kind regards,
|
|
|
You're right, Eager Load Backreference should load the associated entity as part of the initial load. It sounds like this is working in your test project but not in your original project. Is that correct? If so, can you try to isolate the differences between the two projects? I noticed you were using Distinct() in your original query -- I'm not sure if this would make a difference but it might be worth trying taking that out. Can you provide us with a simple repro case for where Eager Load Backreference is specified but is not working? Thanks! |
|
|
Hi Ivan, yes, you did get me right. For the test project eager loading is working as expected while it didn't in my original project. I remove the Distinct() and OrderBy() methods, but I had still no luck :-( I mailed your a test program with that issue. Kind regards, Sörnt |
|
|
There are a couple of issues here, one yours, one ours. The issue on your end is that you're doing the load twice. You have the following code: var query = from u in uow.Users select u; This means the without-the-aggregate query will always execute, regardless of whether you pass in an aggregate. You should be writing: var query = from u in uow.Users select u; However, we have identified a bug in LightSpeed which will cause non-eager-loading behaviour even with this change. I have a fix for this, but in the meantime if you just omit the vacuous from-select syntax (which isn't doing anything for you) then the bug won't manifest: var query = uow.Users; A fix for this issue should be in the 10 April nightly build. |
|
|
Hi Ivan, thank you very much! I wrote the various select statements to find the issue why eager loading didn't work for me. I just aligned the select statments as you suggested but the bug is manifested with the current version. I will wait for the nightly build and give it a try. Kind regards, Sörnt |
|
|
Hi Ivan, the nightly build fixed my issue :-) Thank you very much! Kind regards, |
|