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

String(Null) raises Ambiguous error #284

Closed
rockResolve opened this issue Jul 10, 2019 · 6 comments
Closed

String(Null) raises Ambiguous error #284

rockResolve opened this issue Jul 10, 2019 · 6 comments
Assignees
Labels

Comments

@rockResolve
Copy link
Contributor

When Selecting String(Null) I get the "Ambiguous invocation of 'String' constructor" error.
This seems pointless as any matching constructor should work.

I need the String cast because I Concat this with a query with another and the Concat insists on matching types.

How can I get a Select to return a null string from a literal null?

@StefH StefH added the question label Jul 10, 2019
@StefH
Copy link
Collaborator

StefH commented Jul 10, 2019

Use

qry.Select("string(\"null\")")

@StefH StefH closed this as completed Jul 10, 2019
@rockResolve
Copy link
Contributor Author

rockResolve commented Jul 10, 2019

Oops, my final question should not have mentioned "literal", but rather
How do I select a string with a null value?

qry.Select("string(null)")
throws "Ambiguous invocation of 'String' constructor" error
I need it to be null to force it to the top when sorted with concatenated rows.

@rockResolve
Copy link
Contributor Author

rockResolve commented Jul 10, 2019

Further info ...

It seems String(null) is not valid C#

var x = new System.String(null)
throws error CS0121: The call is ambiguous between the following methods or properties: 'string.String(char*)' and 'string.String(sbyte*)'

FYI I was using String(null) successfully in the old https://github.com/kahanu/System.Linq.Dynamic
ExpressionParser.FindBestMethod returned 0 which triggered GenerateConversion()

@rockResolve
Copy link
Contributor Author

@StefH Could you please revisit this.

How do I create null cast to a String?

@StefH StefH self-assigned this Jan 14, 2020
@StefH StefH added bug and removed question labels Jan 14, 2020
@StefH StefH reopened this Jan 14, 2020
@StefH
Copy link
Collaborator

StefH commented Nov 4, 2020

Hello @rockResolve, can please check with the latest version from System.Linq.Dynamic.Core ?

I think this is fixed, see example: https://dotnetfiddle.net/3cA1gr

@rockResolve
Copy link
Contributor Author

All fixed now. Thanks

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

No branches or pull requests

2 participants