An elegant way to write XML with Linq

While writing out some XML to a file I found a lot nicer way to write out XML while using Linq and the XStreamingElement. The key is to use the XStreamingElement with data from a Linq datasource like so :

The above code will create the xml below (if the data is formatted correctly).:

As an added bonus … Read More

Mike GriffithAn elegant way to write XML with Linq

The type initializer for ‘AutoMapper.TypeMapFactory’ threw an exception. Error with Automapper.

Recently while doing some conversions with Automapper I ran into an error while running it. I was getting the “The type initializer for ‘AutoMapper.TypeMapFactory’ threw an exception.” with an inner exception of “This type is not supported on this platform IDictionaryFactory”. After doing some debugging I finally figured out that it was due to the Automapper dll itself not being … Read More

Mike GriffithThe type initializer for ‘AutoMapper.TypeMapFactory’ threw an exception. Error with Automapper.

Replacing strings with the Filehelpers library.

While working at my current job I’ve been doing a lot of file imports and conversions, so to figure out a more efficient way to do the conversions I did some research and found the FileHelpers library. Now the FileHelpers library makes things very easy to do field conversions by creating attributes that you can connect to each record field … Read More

Mike GriffithReplacing strings with the Filehelpers library.

Building a Windows Service that periodically runs.

Here is some code I threw together to create a windows service that gets called periodically. To use it you’ll have to add this code into the Service class and create an application setting called PollingTime to contain the amount of time between calls of the process. Also note that if the process is still executing then it will block … Read More

Mike GriffithBuilding a Windows Service that periodically runs.

Saving xml from web service calls in .net.

While working on some some web service calls at work I ran into a situation where I needed to record the XML that was being passed from both sides. After doing some Google searching I came across the following code on Microsoft’s site.

Essentially this code hooks into the base web service code and saves the XML that flows … Read More

Mike GriffithSaving xml from web service calls in .net.

Optimizing linq queries with .Any() instead of .Count()

If you have any linq code that looks like this:

Replace it with code that looks like this:

Basically you save time since linq doesn’t need to count each and every record in the collection.

Mike GriffithOptimizing linq queries with .Any() instead of .Count()