开发者

Which method of canonical EntityFunctions for .ToString()

I am using EF and if I use expression like:

JobLinkId = jobItem.joblinkid.ToString()

it throws error because it is C# function. Which method of EF canonical fun开发者_开发知识库ctions should I use for this?


I'm guessing that you're trying to use ToString in Linq to Entities query. If so then its impossible to use it there. The only walkaround i know is to use ToList on query and then use Linq to Objects to get result with ToString.


To something like this:

instead of JobItem.joblinkid.ToString() use only JobItem.joblinkid inside your query and do a select afterwards:

myQuery.ToArray().Select(x => x.joblinkid.ToString())

I hope you get it. In any case: int is better than string, just wait till you really need the string and convert then.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜