Category Archives: C#

Adding a solution to TFS without adding the NuGet packages.

I was adding a project that I just completed to TFS source control and noticed that it wanted to add the packages to source control also, but I didn’t want that because you are not supposed to add the NuGet packages.  They can be re-downloaded and installed during the build process for anyone that does not have them.

I found this nuget link extremely useful on how to configure the solution to 1) Enable the nuget download and 2) keep the packages from being added to source control.

The basic steps are:

            1. Enable the NuGet package restore.  This will add some NuGet stuff to the solution.
            2. Add your project to TFS, then of course commit the change.

C# Parallel Tasks gives MAJOR Speed Increase

I just used parallel tasks to decrease the time a process took from over an hour to about 2 minutes.  I was wary of creating so many database contexts, but it paid off in a major way!

See the snippet of code below to see how I used the Parallel.ForEach.  .Net created almost 100 threads during the execution.

Important
If you need someone with my ability to decrease processing times on a full time basis, please contact me through LinkedIn 

Have a great day!

Learning about SOLID programming principles

I have been learning about SOLID programming principles and I wanted to share the resources that I have found.

First, I listed to the father of these principles describe them on the Hansleman show.  This post obviously caused a few ruffled feathers and for fun, you must listen to show #150 to hear some of the aftermath from Uncle Bob.

Then I found a great youtube video of Steve Bohlen from Microsoft show examples in C# on how these principles can be implemented  and what to look for.  

ToQuarter C# DateTime Extension

I searched on the internet for a quick way to get the Quarter from a DateTime, but I didn’t really find anything useful, so I created this quick extension that seems to work great!  I just wanted to share this to save someone time so they don’t waste the same amount of time that I did.  I am thinking about putting together an open source library to handle many other things like this, what are your thoughts about this?

 

 

 

Converting Oracle Comments to SQL Server.

I downloaded some code a recently that creates an Oracle Database, but I don’t have Oracle, so I converted most of the code to SQL Server.  One of the harder things to convert was the column and table comments.  One of the features of Oracle that Microsoft SQL Server does not have directly is commenting. It appears that you can have comments on a table and comments on a column (field) in the table.

Well after doing some research into how to convert these to SQL Server,  I came across an article at http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=37796 that told how to do this.  Well, I had a script with over 1,100 comments, so I used LinqPad to create a small program that would convert my script using Regular Expressions.

Here is the code for that, please let me know if this helps anyone.  It sure made my work a lot easier.

This is for Table Comments:

And here is the code for Column comments.