温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何用LINQ进行查询

发布时间:2021-12-02 09:18:28 阅读:124 作者:iii 栏目:编程语言
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

本篇内容介绍了“如何用LINQ进行查询”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

LINQ to XML 提供使用 .NET 语言集成查询 (LINQ) Framework 的内存中 XML 编程接口。LINQ to XML 使用***的 .NET Framework 语言功能,相当于更新的和重新设计的文档对象模型 (DOM) XML 编程接口。

LINQ 系列技术提供了针对对象 (LINQ to Objects)、关系数据库 (LINQ to SQL) 和 XML (LINQ to XML) 的一致查询体验。

现在有一个专门的System.Xml.Linq的命名空间

XDocument srcTree = new XDocument(  new XComment("This is a comment"),  new XElement("Root",  new XElement("Child1""data1"),  new XElement("Child2""data2"),  new XElement("Child3""data3"),  new XElement("Child2""data4"),  new XElement("Info5""info5"),  new XElement("Info6""info6"),  new XElement("Info7""info7"),  new XElement("Info8""info8"),  new XElement("Test","Chenxizhang",new XAttribute("ID",10248))  )  )  Console.WriteLine(srcTree);  XDocument doc = new XDocument(  new XComment("This is a comment"),  new XElement("Root",  from el in srcTree.Element("Root").Elements()  where ((string)el).StartsWith("data")  select el  )  );  Console.WriteLine(doc);  Console.Read();

使用命名空间的例子

XNamespace aw = "http://www.adventure-works.com";  XElement root = new XElement(aw + "Root",new XAttribute(XNamespace.Xmlns + "aw""http://www.adventure-works.com"),new XElement(aw + "Child""child content"));  Console.WriteLine(root);  Console.Read(); 

“如何用LINQ进行查询”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI

开发者交流群×