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

Can I convert int to string type? #52

Closed
winsonet opened this issue Nov 1, 2016 · 2 comments
Closed

Can I convert int to string type? #52

winsonet opened this issue Nov 1, 2016 · 2 comments

Comments

@winsonet
Copy link

winsonet commented Nov 1, 2016

I want to do a dynamic field search, so I need to convert all the fields to string for global search, like below:

var expectedResult = _context.Blogs.Select(b => ((string)((int)(b.BlogId))).Contains("key"));
var result = _context.Blogs.AsQueryable().Select("(string((int)BlogId)).Contains(@p)");

but I know that doesn't work, so is there another way I can do ?

Thanks!

@winsonet
Copy link
Author

winsonet commented Nov 1, 2016

Oh, sorry, I have solved this issue, it just can use ToString() for convert to string as below:

var expectedResult = _context.Blogs.Select(b => ((int)(b.BlogId)).ToString().Contains("aa"));
var result = _context.Blogs.AsQueryable().Select("(int(BlogId)).ToString().Contains(\"aa\")"); 

but I don't know why the ToString() can't use to format a DateTime value ( My another issue)

@StefH
Copy link
Collaborator

StefH commented Nov 8, 2016

closing this one...

@StefH StefH closed this as completed Nov 8, 2016
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