Extension methods using C#

During my time working, I find that developers can get lazy and start using the COPY and PASTE commands to a degree that can make code unmanageable.

There are many things we can do to reduce, if not eliminate, the code management nightmare, however, the one way I will focus on is using extension methods.

Read more “Extension methods using C#”

How To Do A Multi-Column Join In LINQ

This is an exclusive guest post from Shaun Tirubeni, please visit his blog located here for more of his work.

Since we live in a complex world, creating even a simple application takes a fair amount of effort. We do multi-column joins every day using SQL. Many companies are moving away from raw SQL and stored procedures to ORMs and other layers of abstraction.

Read more “How To Do A Multi-Column Join In LINQ”

LINQ Expression – how to append to an expression at a later stage

The cool thing with LINQ and Entity framework is that if you pass an expression through to you context, it creates an SQL Query based of that expression to fetch the data you need, instead of fetching loads of data down and having to sift through them in C#.

A recurring issue that plagued me was that if I needed to pass through a slightly different LINQ expressions based on certain conditions it looked like I was repeating code, and I don’t like repeating code.

after a few hours of playing around with different techniques I devised a little way to append to an expression.
Read more “LINQ Expression – how to append to an expression at a later stage”

How to manage SQL Server Agent jobs through Csharp

Please note this is an expansion to the article on HOW TO ALLOW A USER WITH AN SQL LOGIN TO MANAGE SQL SERVER AGENT.

The entire source code, with comments, for this tutorial can be downloaded here.

in the mentioned article we learnt how to set up an SQL user to manage SQL Jobs, in this article we are going to learn how to manage jobs through a C# application,
and we will be using the SQL user created in the mentioned article to connect to the database and actually mange the SQL Server Agent jobs.

  1. We will be creating a class library named “SQLServerJobUtility” which will contain the functionality required to manage SQL Server Agent jobs
  2. We will be creating a console application to make use of this class library

Please NOTE: SQL Server 2008 R2 or later must be installed on your development machine.

What tools am I using ?

  1. Microsoft Visual Studios 2012
  2. Microsoft SQL Server 2012 with Management studio

Read more “How to manage SQL Server Agent jobs through Csharp”

How to resolve “SqlClrProvider not found” without installing sql server on the client machine or needing a deployment project

While working on a project I needed to start and stop SQL jobs via a web application, this worked great on my local machine but as soon as I published to the client web server I started getting SQLClrProvider not found exceptions.

For some reason this DLL is not readily available on the windows system so it’s not as simple as dropping a DLL into the bin folder, however the DLL does exist in the GAC (on your local machine, or any machine with SQL Server Installed)
Read more “How to resolve “SqlClrProvider not found” without installing sql server on the client machine or needing a deployment project”