SQL Server SYNONYM

I’ve recently been working on an application which has to make use of data from within two databases (one onsite and one remote) with SQL generated to query the two databases along the lines of:

SELECT a.*, b.*
FROM [TableA] a
INNER JOIN [DatabaseB].[SchemaB].[TableB] b ON a.ID = b.ID

Referencing the second database using its full name is annoying to type but also limiting.  Imagine if you were working on a couple of projects, each of which used the same version DatabaseA, but which needed to reference different versions of DatabaseB.  If you were developing each of these databases in SQL Server you’d have to call the second version of DatabaseB something different which would end up breaking your SQL as it specifically references DatabaseB by name. Continue reading

using Statement

A question I’m asked from time to time is why and when should I use a using statement within my code.

For me, using statements are all about convenience.  They provide a nice simple way of ensuring that I am using IDisposable objects correctly, plus I also like tidy code.  What’s an IDisposable object?  It’s an object which implementes the IDisposable interface, which from a coding perspective means that you have access to a .Dispose() method Continue reading

.Net DNS Lookups

DNS lookups.  Generally a pain and difficult to do in .Net.  The built in Dns class from the System.Net namespace provides a nice way of resolving an IP address or host name via its GetHostEntry() method but if you want to delve a little further into the DNS record then you’re screwed.

As a fan of nuget I thought I would take a browse through its repository and see if anyone had written a nice wrapper class that could help me out. Continue reading