zoukankan      html  css  js  c++  java
  • Linq使用(3)

             1.     XDocument doc = XDocument.Parse(returnValue.Trim());
                  var cdistinct = doc.Descendants("reportname").Where(p => Convert.ToString(p.Element(x).Value).Trim() != "").Select(p => Convert.ToString(p.Element(x).Value)).Distinct();
                  string[] dataDistinct=new string[cdistinct.Count()];
                   int i=0;
                   foreach (var count1 in cdistinct)
                  {
                      dataDistinct.SetValue(count1, i);
                      i++;
                  }
                   return dataDistinct;

     

                2.  XElement xml = XElement.Load(文件地址名称);  //定义查询方法                                    

                 var query = from c in  xml.DescendantsAndSelf("Customers")

                  select new CustomerInfo                    

                {                        

                   CustomerID = c.Elements("CustomerID").SingleOrDefault().Value,              

                   CompanyName = c.Elements("CompanyName").SingleOrDefault().Value,        

                      ContactName = c.Elements("ContactName").SingleOrDefault().Value,          

                    ContactTitle = c.Elements("ContactTitle").SingleOrDefault().Value,                

                   Address = c.Elements("Address").SingleOrDefault().Value,            

                   City = c.Elements("City").SingleOrDefault().Value,    

                          PostalCode = c.Elements("PostalCode").SingleOrDefault().Value,            

                  Country = c.Elements("Country").SingleOrDefault().Value,                

                  Phone = c.Elements("Phone").SingleOrDefault().Value,      

                        Fax = c.Elements("Fax").SingleOrDefault().Value,          

                    Region = c.Elements("Region").SingleOrDefault().Value != "" ? true : false

                  };         

  • 相关阅读:
    中关村的那些黑暗的事——北漂18年(17)
    TRS OM error
    The user specified as a definer ('root'@'%') does not exist
    Spring 配置标签——util标签
    关于spring中<util:/>的配置
    Spring配置文件中指定init-method属性的作用
    spring
    could not insert: [com.trs.om.bean.UserLog] The user specified as a definer ('root'@'127.0.0.1') does not exist
    org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.trs.om.bean.User.retryCount
    U盘安装win7 raid设置
  • 原文地址:https://www.cnblogs.com/sunrise/p/1614575.html
Copyright © 2011-2022 走看看