.NET Console Application Using Linq (to sql, to xml)
.NET, Database November 16th, 2008Last week I had to transfer data from an old database to a refactored one (linq to sql). To do this I also needed to read in more than thousand Xml-files (linq to xml) to map certain Id’s from the old database to Id’s of the new refactored database.
I thought this to be a good opportunity to look at Linq and use it in practise. It was fun, it was really fun and mostly quick, very quick. Linq is excellent for little projects or console applications like mine here. If it’s usefull in big projects I wouldn’t know. There’s also the Entity Framework I should have a look at to answer this question (discussions on this you’ll find plenty if you google for a split second…).
Anyway, I easily created a datacontext for the old database and another for the refactored database. I did have some problems with identical tables in both databases, so I had to change some names. But everyting went very smooth. The queries are extremely easy to create, updating and creating records is a piece of cake and accessing a table is as easy as dragging the table from the server explorer in the dbml file.
I had one book next to me which helped me a lot:
Besides the I also used this link a lot.
One thing I did search a while for is the transact SQL coalescing equivalent. In C# the equivalent is ??.
Have a look at this link to find out more.
Ciao, Lieven Cardoen aka Johlero
Recent Comments