LINQ
Posted tangpeng97
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LINQ相关的知识,希望对你有一定的参考价值。
XML处理
1.How to create xml ?
XDocument customer = new XDocument( new XDeclaration("1.0", "UTF-16", "yes"), new XElement("customer", new XAttribute("id", "C01"), new XElement("firstName", "Paolo"), new XElement("lastName", "Pialorsi"), new XElement("addresses", new XElement("address", new XAttribute("type", "email"), "paolo@devleap.it"), new XElement("address", new XAttribute("type", "url"), "http://www.devleap.it/"), new XElement("address", new XAttribute("type", "home"), "Brescia - Italy"))));
LINQ create xml document is very easy,and clearly.
2.How to create xml in loop
//1.Declare Xdocument and have to set root node XDocument Content = new XDocument( new XElement("json") ); //2.Add element to document XAttribute ID = new XAttribute("id", 1); XElement XmlElement = new XElement("School", ID, "南十三大学"); Content.Root.Add(XmlElement);
3.How to remove all nodes attributes?
Content.Descendants().Attributes().Remove();
4.XmlReader how to read xml document content?
XmlReader reader = Content.Root.CreateReader(); reader.MoveToContent(); string result = reader.ReadInnerXml();
以上是关于LINQ的主要内容,如果未能解决你的问题,请参考以下文章
ASP.NET MVC4.0+EF+LINQ+bui+网站+角色权限管理系统
解决未能加载文件或程序集“Newtonsoft.Json ...."或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)(代码片段