在ASP.NET页面上,我有一个配置了以下SELECT命令的SqlDataSource:
SELECT AVG(Rating) FROM [Ratings] WHERE ([AlbumID] = @AlbumID)
我如何将该平均值放入标签中?
什么是'@'在ActionScript中做什么?无法在任何地方找到相关信息,主要是因为Google和其他搜索引擎会从搜索查询中删除特殊字符.
这是我想要做的:
string parseCode = from x in xml.Descendants("LogType")
where x.Attribute("ID").Value == string)ddlHistoryLogDefinitions.SelectedValue
select x.Attribute("ParseCode").Value;
Run Code Online (Sandbox Code Playgroud)
但是这会产生错误:"无法将类型'System.Collections.Generic.IEnumerable'隐式转换为'string'"
只有一个值,x.Attribute("ParseCode")但它坚持返回类型IEnumerable<string>.如何将该值提取到字符串中?
编辑:谢谢你的回复.这对我有用:
string parseCode = (from x in xml.Descendants("LogType")
where x.Attribute("ID").Value == (string) ddlHistoryLogDefinitions.SelectedValue
select (string) x.Attribute("ParseCode").Value).FirstOrDefault();
Run Code Online (Sandbox Code Playgroud)
这个技巧是在.FirstOrDefault()之前将整个linq查询包装在()中.