jeudi 17 décembre 2015

Match the nodes in xml to Entity framework class

I have a sql server DB with bunch of tables in it. In one table called orders I have about 20 fields of various types. Every night, I get this xml file that I'm support to parse and insert in the table. The problem is that the xml snippet for the order node is always a subset of the number of columns that I have in that table. In one node, I can have 4 fields. Yet, in another node (same xml file), I can 9 fields. But again, the xml order node is always a subset of the columns that I have in the orders table.

Now I can theoretically layout all the 20 fields and match them one by one to the xml file regardless whether I have that element or not. And if I don't, I can wrap the darn thing in try/catch and set it to null in catch block if the element doesn't exists. But that's so 90's. Is there a dynamic way of doing this?





Aucun commentaire:

Enregistrer un commentaire