我正在尝试执行 LINQ to JSON 的示例代码(如下所述),但它给了我以下错误
堆栈跟踪:
[InvalidOperationException:Lambda 参数不在范围内]
我正在执行的代码是:
JObject rss =
new JObject(
new JProperty("id", "James Newton-King"),
new JProperty("name", "http://james.newtonking.com"),
new JProperty("data", "James Newton-King's blog."),
new JProperty("children",
new JArray(
from p in mwsysbot.Software
where p.SoftwareName == name
select new JObject(
new JProperty("id",p.SoftwareUUID),
new JProperty("name", p.SoftwareName)
)
)
)
);
此外,当我删除行“new JProperty("name", p.SoftwareName)”时,代码执行得很好。
为什么?