Generated SQL with PredicateBuilder, LINQPad and ANY Statement

I previously asked about setting up chains in Linq To Entities. Now I am using LinqKit and everything works fine. I want to see the generated SQL, and after reading this answer , I use LinqPad .

This is my statement:

var predProduct = PredicateBuilder.True<Product>();
var predColorLanguage = PredicateBuilder.True<ColorLanguage>();

predProduct = predProduct.And(p => p.IsComplete);

predColorLanguage = predColorLanguage.And(c => c.IdColorEntity.Products.AsQueryable().Any(expr));

ColorLanguages.Where(predColorLanguage).Dump();

The code works in VS2008, compiles and creates the correct result set, but in LinqPad I have the following error:

NotSupportedException: The overload query operator 'Any' used is not Supported.

How can I see the generated SQL if LINQPad crashes?

EDIT

If i write

var predColorLanguage = PredicateBuilder.True<ColorLanguage>();

predColorLanguage = predColorLanguage.And(c => c.IdColorEntity.Products.Any((p => p.IsComplete));

ColorLanguages.Where(predColorLanguage).Dump();

works ... WTF?

+2
source share
1 answer

LINQKit, , Compile() , EntitySet, AsExpandable() :

var predProduct = PredicateBuilder.True<Product>();
var predColorLanguage = PredicateBuilder.True<ColorLanguage>();

predProduct = predProduct.And(p => p.IsComplete);

predColorLanguage = predColorLanguage.And (
  c => c.IdColorEntity.Products.Any(predProduct.Compile()));

ColorLanguages.AsExpandable().Where(predColorLanguage).Dump();

LINQKit, : AsExpandable , LINQ to SQL.

+2

Source: https://habr.com/ru/post/1687366/


All Articles