-
-
Notifications
You must be signed in to change notification settings - Fork 231
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
Question: why is Distinct not supported? #21
Comments
ok! that's great, I'll try it asap |
Code + tests have been added to Github. Please take a look. |
thank you, yes a new nuget would be great to test it |
Are you able to verify ? |
I tried but I'm having problems, how can I retrieve a distinct list of Persons by name? (like the commented line). This is my code
gives a ParseException
|
You can do this: Or is the method you are looking for like: |
Yes, your sample works, but I couldn't think of a dynamic use for it since Distinct is explicit. Also I can't seem to use Distinct inside a Where.("...") expression. I'm working on a Linq to Entities (SQL Server) project using the original @NArnott library and some complex queries aren't easy to manage without support for Distinct and GroupBy methods. |
Can you provide an example for the _Where_ statement ? Because _Select_ is supported : |
I'll answer with a sample asap. what is "abc" in your code sample? |
A property from a user which is a list or iqueryable or ienumerable. See https://github.com/StefH/System.Linq.Dynamic.Core/blob/master/test/System.Linq.Dynamic.Core.Tests/QueryableTests.Distinct.cs#L35 |
Any luck? |
Sorry mate, didn't have time to check it in these days. I'll write here when I have a couple more samples. keep on the good work |
Can you provide feedback ? |
Ok let's forget about Distinct() support in Where. My situation was an extreme case and it's not worth replicating. About Distinct in select I can't seem to make it work for simple lists (not nested object like your code sample) This is my code:
Maybe it's me that is not undertanding how this works. is there any way to achieve what I'm trying to do? if not, and if it's not useful to implement it, we can close this issue. |
Distinct does not solve your problem I think: In your original question: // real linq
var qp = lp.AsQueryable().Select(p => p.Name).Distinct();
// dynamic linq
var qpDynamic = lp.AsQueryable().Select("Name").Distinct(); The value from qp will be a List of Strings with the values : "John", "Paul" and "Ringo". What you are trying do does not make sense I think, I have a feeling you want to use a groupby logic. var error = lp.AsQueryable().Select(p => p.Name.Distinct()); does also not compile. |
Ok, thanks, that makes perfect sense, I'll close the issue. |
Distinct() method is not supported, not in the original @NArnott project (now disappeared.. why?) and not in this fork. what's the reason behind it? is it too difficult to implement?
The text was updated successfully, but these errors were encountered: