usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Linq;usingSystem.Xml.Linq;usingSystem.Xml;usingSystem.Windows.Forms;namespaceconsoleapplication27{classProgram {[STAThread]Static voidMain (string[] args) { ////Note that the xmlns in the Hibernate mapping file causes the LINQ to XML query not to correspond to the node, so I'll change the xmlns to xmlns1, then replace it with the full text afterwards . varPath = AppDomain.CurrentDomain.BaseDirectory +".. \\.. \\Mapping\\PosPositionProductMapping2.hbm.xml"; varRoot =xelement.load (path); varCPS = root. Elements ("class"). Elements (" Property"). ToList (); BOOLFind1 =false; BOOLFind2 =false; Cps. ForEach (c= { stringColumnvalue = C.attribute ("column"). Value; if(Columnvalue.tolower (). Contains ("Created_employee_name". ToLower ())) {Find1=true; } if(C.attribute ("column"). Value.tolower (). Contains ("created_employee_id". ToLower ())) {Find2=true; } }); XElement CLS= root. Element ("class"); if(find1==false) {XElement XE=NewXElement (" Property", NewXAttribute ("name","Createdemployeename"), NewXAttribute ("column","Created_employee_name"), NewXAttribute ("Update","false") ); Cls. ADD (XE); } if(find2==false) {XElement XE=NewXElement (" Property", NewXAttribute ("name","Createdemployeeid"), NewXAttribute ("column","created_employee_id"), NewXAttribute ("Update","false") ); Cls. ADD (XE); } root. Save (path); } }}
The xmlns in the Hibernate mapping file causes the LINQ to XML query to not reach the corresponding node