Home / Archive by category 'Programming'

| RSS

Free Download CodeRush Xpress For C#

Developer Express the company that produces some of the best third party control libraries for .NET also have two very popular products for developer productivity. These products are CodeRush and Refactor Pro retailing for approximately $250. They have now released a free edition of CodeRush called CodeRush Xpress which can be downloaded here.
Even though Xpress [...]

[ More ] November 4th, 2008 | 1 Comment | Posted in Programming |

Download Visual Studio 2010 And .NET Framework 4.0 CTP

CTP of Visual Studio 2010 and .NET Framework is now available for download. Visual Studio 2010 takes the world’s best IDE to the next level by innovating on many fronts. Here is an overview from the download page.
Visual Studio 2010 and the .NET Framework 4.0 mark the next generation of developer tools from Microsoft. [...]

[ More ] October 29th, 2008 | 1 Comment | Posted in Programming |

View T-SQL Query Generated By LINQ To SQL Using Linqpad

In my previous post I showed you three different ways to capture the T-SQL query generated by LINQ To SQL. A comment on the post reminded me that I forgot to mention a fourth way i.e. using Linqpad. In Linqpad when you have executed the query you can click on the SQL tab next to [...]

[ More ] September 23rd, 2008 | 4 Comments | Posted in Programming |

View T-SQL Query Generated By LINQ To SQL

While working with LINQ To SQL there are times when you are interested in looking at the query which will be executed on the database.  This post will cover different ways you can capture the query generated by LINQ To SQL.
SQL Server Profiler
SQL Profile has long been a preferred tool to capture activity on a [...]

[ More ] September 22nd, 2008 | 4 Comments | Posted in Programming |

Code Sample: Programmatically Download File Using C#

While browsing forums today I came across a question which asked for a solution to download a file from a web server programmatically. The solution is very simple and below is the code which achieves the goal. Here I am downloading a file asynchronously on Button Click.

1: private void buttonDownloadFile_Click(object sender, EventArgs [...]

[ More ] September 17th, 2008 | 10 Comments | Posted in Programming |

Code Sample: Find Difference Between Two DateTime Values

This code shows you how to find the difference between two DateTime values. The easiest way to do this is to use the TimeSpan class and subtract one DateTime from another.

DateTime firstDate = new DateTime(2008, 8, 1);
DateTime secondDate = DateTime.Now;

TimeSpan timeSpan = secondDate.Subtract(firstDate);

// Get Difference
Console.WriteLine(”Days : ” + timeSpan.Days.ToString());
Console.WriteLine(”Hours : ” + timeSpan.Hours.ToString());
Console.WriteLine(”Minutes : [...]

[ More ] September 17th, 2008 | No Comments | Posted in Programming |

Use SqlConnection With LINQ To SQL

LINQ To SQL allows us to use a SqlConnection object to connect to a database. The way to use a SqlConnection is to pass it as a parameter to DataContext object. DataContext object has constructor which takes in a IDbConnection and SqlConnection implements this Interface. Here I create a SqlConnection object and use it to [...]

[ More ] September 16th, 2008 | 4 Comments | Posted in Programming |

LINQ To SQL Join On Multiple Conditions

LINQ To SQL or just plain LINQ allows us to do a join on multiple conditions using an elegant technique. In this post I will show you how to perform a Join on multiple conditions. As an example I will take two tables called House and ShoppingMall.

Both these tables have PostCode and CouncilCode as common [...]

[ More ] September 16th, 2008 | 11 Comments | Posted in Programming |

Fundamentals: Deep Cloning In C#

To make an object cloneable in .NET we should implement ICloneable interface. ICloneable is a simple interface with only one method Clone(). In this post I will show you how to make a deep clone of an object.

class Program
{
static void Main(string[] args)
{
[...]

[ More ] September 1st, 2008 | 2 Comments | Posted in Programming |

Use EDMGEN To Generate Entity Framework Model

.NET Framework 3.5 SP1 ships with a tool called edmgen. This tool can be used to generate the EDM (Entity Data Model). Being a command line tool it can be executed from a batch file or a Powershell script.
Edmgen can be used to generate either a full model or selected artifacts such as CSDL, MSI, [...]

[ More ] September 1st, 2008 | No Comments | Posted in Programming |

Get A List Of Installed Applications Using LINQ And C#

To get a list of installed applications we need to look into registry. Microsoft.Win32 namespace contains objects which can be used to work with Windows Registry. In this post I will show you some code where I use the power of LINQ to retrieve and display a list of all applications installed on a machine.
The [...]

[ More ] August 29th, 2008 | 14 Comments | Posted in Programming |

Programmatically Retrieve Information About Windows Services Using ServiceController

ServiceControl can be used to get information about a Windows Service on a machine.  In this post I will show you how to retrieve information about a service using ServiceControl.
To begin with lets examine the properties for ServiceControl. Through the designer we can set the ServiceName property. This can be set to the name of [...]

[ More ] August 29th, 2008 | No Comments | Posted in Programming |