【发布时间】:2014-07-31 18:24:19
【问题描述】:
我有代码
foreach (XElement t in selxml.Elements("Type"))
printxml.Add(new XElement("Type",
new XAttribute("TypeID", t.Attribute("ID").Value),
new XAttribute("TypeName", (from pt in fdb.PrintTypes where pt.PrintTypeID == Int32.Parse(t.Attribute("ID").Value) select pt.Name).SingleOrDefault()),
new XAttribute("Value", t.Attribute("Value").Value),
new XAttribute("ValueName", (from pti in fdb.PrintTypeItems
where pti.Value == Int32.Parse(t.Attribute("Value").Value) &&
pti.PrintTypeID == Int32.Parse(t.Attribute("ID").Value)
select pti.Name).SingleOrDefault())));
和VS说
LINQ to Entities 无法识别方法 'Int32 Parse(System.String)' 方法,并且该方法无法翻译 到商店表达式中。
为什么选择 LINQ to Entity?这是 Linq 到 XML。我该如何解决这个问题?
【问题讨论】:
-
是的,但是您有一个 L2E 嵌套查询,它不支持
Int32.Parse -
@James h如何使使用 L2XML 嵌套 L2E 成为可能?
标签: c# xml entity-framework