Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why doesn’t relationship span happen with MergeOption.NoTracking?

doesn’t relationship span
0
10 Posted

Why doesn’t relationship span happen with MergeOption.NoTracking?

0

The basic reason the EF doesn’t do relationship span with NoTracking queries is that NoTracking queries were designed to be as absolutely high performance as possible. We didn’t want to rewrite those queries to bring back additional data (which could possibly require a join to draw the data from a link table or something) unless the user explicitly asked for it. In the case of standard tracking queries, the stubs are so important that we decided to just turn it on by default, but for NoTracking queries that didn’t seem like the right answer. While this info isn’t returned by default, you can usually rewrite the queries yourself to retrieve this information in a fairly straightforward fashion. For instance, if you were querying for orders and wanted to bring back the key of the related customer, then you could do something like this: var query = ctx.CreateQuery(“select o, Ref(o.Customer) from Orders as o”); query.MergeOption = MergeOption.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.