将 linq 查询的输出转换为字符串时出现问题
我很抱歉问这个基本问题,
var filePath = (from Component comp1 in componentContainer where comp1.ComponentName == fileName select comp1.FilePath);
我想将输出转换为字符串。
我尝试了这些事情:
string filePath = (from Component comp1 in componentContainer where comp1.ComponentName == fileName select comp1.FilePath).ToString();
两次
var filePath = (from Component comp1 in componentContainer where comp1.ComponentName == fileName select comp1.FilePath);
string filePathInString = filePath.ToString();
我都收到错误:
Linq.Internals.UnoptimizedQuery<string>
请帮助我
我应该如何解决这个问题?
PS:如果有人认为这个问题很愚蠢或者出于某种原因不喜欢它。您可以在得到答案后删除此问题,而不是对其进行标记或否决
I'm sorry to ask this basic question,
var filePath = (from Component comp1 in componentContainer where comp1.ComponentName == fileName select comp1.FilePath);
I want to convert the output to string.
I tried these things:
string filePath = (from Component comp1 in componentContainer where comp1.ComponentName == fileName select comp1.FilePath).ToString();
and
var filePath = (from Component comp1 in componentContainer where comp1.ComponentName == fileName select comp1.FilePath);
string filePathInString = filePath.ToString();
both times i'm getting error:
Linq.Internals.UnoptimizedQuery<string>
Please help me out
How should i solve this problem ?
PS: If some one thinks this question is stupid or for some reason does not like it. U may delete this question after getting answered instead of flagging or down voting it
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试将查询更改为
Try changing the query to