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

Casting a int to a nullable int will throw an error when using linq to entities"Only parameterless constructors and initializers are supported in LINQ to Entities" #44

Closed
lennyf opened this issue Sep 14, 2016 · 1 comment
Assignees

Comments

@lennyf
Copy link

lennyf commented Sep 14, 2016

Using an expression in the following format - MyDbSet.Select("new (int?(Id))") will throw an error if the Id property is of type int. This seems to be a bug in the original System.Linq.Dynamic project too.

One work around I have found is you can cast it to int64 first and then a nullable int like so MyDbSet.Select("new (int?(int64(Id)))")

The error only gets thrown once you try to evaluate the expression e.g. calling Count() on the first example

@StefH StefH self-assigned this Sep 14, 2016
StefH added a commit that referenced this issue Sep 28, 2016
@StefH StefH closed this as completed in cb04999 Apr 15, 2017
StefH added a commit that referenced this issue Apr 15, 2017
@StefH
Copy link
Collaborator

StefH commented Apr 15, 2017

@lennyf Please test with latest code.

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

2 participants