Category:ASP.NETC#
Article From:https://www.cnblogs.com/Jeremy2001/p/9124290.html
DataTable dt = PurchaseArriveInfoBus.GetPurchaseArriveInfo(companyCD, txtArriveNo, txtTitle, txtProvider);
        XElement dsXML = ConvertDataTableToXML(dt);
        //linqsortVar dsLinq =(order = = "ascending")?(from X in dsXML.DescendantS ("Data")Orderby x.Element (orderBy).Value ascendingSelect new DataSourceModel (){ID = x.Element ("ID").Value,ArriveNo = x.ElEment ("ArriveNo").Value,Title = x.Element ("Title").Value,ProvideRID = x.Element ("ProviderName").Value,Purchaser = x.Element ("Purchaser").Value,ProductNo = x.Element ("ProductNo").Value,ProductName = x.Element ("PRoductName ").Value,ColorName = x.Element ("ColorName").Value,TotalPrice = x.Element ("TotalPrice").Value,ProductCount = x.Element ("ProductCount").Value,InCount = x.Element ("InCount").Value,DetaiLID = x.Element ("DetailID").Value,UnitName = x.Element ("UnitName").Value,JiBenCount = x.Element ("JiBenCount").Value,UnitPrice = IsDisplayPrice? X.Element ("UnitPrice").Value: "0"}):(fromX in dsXML.Descendants ("Data")Orderby x.Element (orderBy).Value descendingSelect new DataSourceModel (){ID = x.Element ("ID").Value,ArriveNo = x.Element ("ArriveNo").Value,Title = x.Element ("Title").Value,ProviderID = x.Element ("ProviderName").Value,Purchaser = x.Element ("Purchaser").Value,ProductNo = x.Element ("ProductNo").Value,ProdUctName = x.Element ("ProductName").Value,ColorName = x.Element ("ColorName").Value,TotalPrice = x.Element ("TotalPrice").Value,ProDuctCount = x.Element ("ProductCount").Value,InCount = x.Element ("InCount").Value,DetailID = x.Element ("DetailID").Value,UnitName = x.Element ("UnitName ").Value,JiBenCount = x.Element ("JiBenCount").Value,UnitPricE = IsDisplayPrice? X.Element ("UnitPrice").Value: "0"});Int totalCouNT = dsLinq.Count ();

  dsLinq.Count() An exception of “System.NullReferenceException” type has been triggered, and no field can be null.

Leave a Reply

Your email address will not be published. Required fields are marked *