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 comp开发者_开发技巧1.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
Try changing the query to
string filePath = (from Component comp1 in componentContainer where comp1.ComponentName == fileName select comp1.FilePath).FirstOrDefault().ToString();
string filePath=componentContainer.Single(x=>x.ComponentName==fileName).FilePath;
精彩评论