Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QueryRewrite: implement complex cases of entity equality and enable relevant tests #15260

Open
maumar opened this issue Apr 5, 2019 · 1 comment

Comments

@maumar
Copy link
Contributor

maumar commented Apr 5, 2019

example query:

from p in ps
where p.OrderDetails.Contains(
	ods.OrderByDescending(o => o.OrderID).ThenBy(o => o.ProductID)
		.FirstOrDefault(orderDetail => orderDetail.Quantity == 1))
select p

this can be translated to:

from p in ps
where p.OrderDetails.Select(x => x.Id).Contains(
	ods.OrderByDescending(o => o.OrderID).ThenBy(o => o.ProductID)
		.FirstOrDefault(orderDetail => orderDetail.Quantity == 1).Id)
select p

but in case of composite keys we need to be more creative, e.g.

from p in ps
where p.orderDetails.Join(
		ods.OrderByDescending(o => o.OrderID).ThenBy(o => o.ProductID)
			.Where(orderDetail => orderDetail.Quantity == 1).Take(1),
			p => { p.Key1, p.Key2 }, od => { od.Key1, od.Key2 }).Any()
@smitpatel
Copy link
Member

Related #20164

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants