Open monstress2 opened 11 months ago
if used "WrappedConstant" technique, there no exception.
var q = context.Roots;
var qW = ExpressionHelper.WrappedConstant(q);
var qDynGood = q.Where(c, "@0.Count(it.Id == root.Id) > 0", qW);
qDynGood.ToArray();
@monstress2
I think your code fails because root
is a reserved word in System.Linq.Dynamic.Core
Can you try naming your entity differently.
Or set AreContextKeywordsEnabled
to false
:
https://dynamic-linq.net/advanced-configuration#arecontextkeywordsenabled
@monstress2 I think your code fails because
root
is a reserved word in System.Linq.Dynamic.Core
For better understanding, I rewrite code (renames vars):
var qRoot = context.Some1;
var qSub = context.Some1; //here may be any other query (DBSet)
//qRoot.Where(x => qSub.Count(t => t.Id == x.Id) > 0)
var qRes = qRoot.Where(_, "@0.Count(it.Id == root.Id) > 0", qSub);
qRes.ToArray(); //throw exception
I guess qRoot.Where(_, "@0.Count(it.Id == root.Id) > 0", qSub)
is equal qRoot.Where(x => qSub.Count(t => t.Id == x.Id) > 0)
. Am I wrong?
I use the word root
to get ID the top query record (qRoot
). In this example I could use parent
instead of root
. But it's the same result.
And than I want to compare it with ID subquery(@0
=== qSub
) record:
:small_orange_diamond: qRoot.Where("@0 :small_blue_diamond:.Where(:small_orange_diamond: root.ID == it.ID :small_blue_diamond: ).Count() > 0", qSub :small_blue_diamond:);
As I already wrote above. I have a solution to the problem. I use a wrapper for the subquery parameter. But I think you might want to improve your library. You can close the issue if this is not a bug.
Thanks you anyway.
Hi. Sub query throw error: