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

Please add some "in clause" examples to your docs #816

Open
Nefcanto opened this issue Jun 9, 2024 · 0 comments
Open

Please add some "in clause" examples to your docs #816

Nefcanto opened this issue Jun 9, 2024 · 0 comments

Comments

@Nefcanto
Copy link

Nefcanto commented Jun 9, 2024

I'm trying to create an in clause query using dynamic linq. I tried:

dbSet<T>.AsQueryable().Where($"Key in @0", keys);

And I got this error:

An exception of type 'System.InvalidOperationException' occurred in System.Linq.Expressions.dll but was not handled in user code: 'No generic method 'Contains' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic. '

I tried:

dbSet<T>.AsQueryable().Where($"Key.In(@0)", keys);

And I got the same error. Please note that values is an array of keys:

var values = new string[] { "pump", "motor" };

Then I tried:

dbSet<T>.AsQueryable().Where($"@0.Contains(Key)", keys);

No exception, but I got this translation, which is wrong:

AND (h.Key IS NOT NULL AND ((LOCATE(h.Key, 'pump') > 0) OR (h.Key LIKE '')))

Unfortunately, your documentation does not have examples related to how to generate the in clause. And these erroneous codes are proposed by AI (ChatGPT and Gemini).

I did not create an MRE (minimally reproducible example) because it's all about docs. Please add some examples to the docs. Thank you.

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

No branches or pull requests

1 participant