diff --git a/Orm/Xtensive.Orm.Tests/Linq/InTest.cs b/Orm/Xtensive.Orm.Tests/Linq/InTest.cs index 05a57056c..ff8ebad93 100644 --- a/Orm/Xtensive.Orm.Tests/Linq/InTest.cs +++ b/Orm/Xtensive.Orm.Tests/Linq/InTest.cs @@ -583,6 +583,23 @@ public void CompiledInTest() Assert.AreEqual("Leonie", result2[0]); } + [Test] + public void UnusedLetImpactsQueryTest() + { + var allIds = Session.Query.All().Select(o => o.InvoiceId).ToArray(); + var existingIds = allIds.Take(2).ToArray(); + var nonExistingIds = new[] { allIds.Max() + 1 }; + var count1 = (from invoice in Session.Query.All() + where invoice.InvoiceId.In(existingIds) + select invoice).Count(); + var count2 = (from invoice in Session.Query.All() + let foo = invoice.InvoiceId.In(nonExistingIds) + where invoice.InvoiceId.In(existingIds) + select invoice).Count(); + Assert.Greater(count1, 0); + Assert.Greater(count2, 0); + } + private IEnumerable GetCustomers(params string[] customerNames) { return Session.Query.Execute(qe => qe.All().Where(customer => customer.FirstName.In(customerNames)));