Re-Linq: Custom result operator's query source name.

55 views
Skip to first unread message

Alexander Zaytsev

unread,
Nov 26, 2018, 12:05:15 AM11/26/18
to re-moti...@googlegroups.com
Hi all,

I'm trying to implement a custom result operator to attach query hints/lock modes for NHibernate. So, far I came up with the following query: 
from c in db.Customers.WithLock(LockMode.Upgrade)
from o in c.Orders.WithLock(LockMode.Upgrade)
select new {o, c}
I want to be able to resolve a name of the query source ("c" and "o" respectively) as I need this information later. 

I'm trying to get QuerySourceReferenceExpression using Resolve method (resolve identity lambda _=>_). But because I apply the result operator before the query source got it's name I'm getting "<generated>_X" as a name for both query source. However, for some reason, the both names are generated as <generated>_1 (I think this is because they are on different QueryModel's (one is on subquery, and one is on main, and they do not share the uniqueNameGenerator). 

Any suggestions how I could achieve this?

Best Regards,
Alexander


Michael Ketting

unread,
Dec 2, 2018, 5:31:23 AM12/2/18
to re-motion Users
Hi Alexander,

I'm sorry, I can't really give you a good answer at this point without setting up an implemntation sample etc. Using ResultOperators inside a query (as compared to the end of the query) will result in sub queries. That's probably why you're getting the different IDs, too. It's probably easier to use extension methods with expression transformers instead. We don't have query hints for our own SQL Backend yet so I can't point you to a working expample.

I've checked and EntityFramework.Core also has an implementation of query hints using result operators: https://github.com/ralmsdeveloper/EntityFrameworkCore/commit/28fa9882785211762fddc1fc7e8220735959c480 but I don't know if they have solved the sub query issue.

Best regards, Michael
Reply all
Reply to author
Forward
0 new messages