+5  A: 

Let's take this bit of code as an example:

string aliSpReqs = String.Empty;

foreach (var item in dc.TaskRelations.Where(tableRaletions => 
                  tableRaletions.TaskId == taskID 
                  && tableRaletions.RelTypeId == 13))
{
    aliSpReqs += item.RefAliSpReq.shortdesc + "; ";
}
return aliSpReqs.Substring(0, aliSpReqs.Length - 2);

You're concatenating strings in a loop. That's a bad idea. Instead, try this (assuming .NET 4):

var query = c.TaskRelations.Where(r => r.TaskId == taskID 
                                       && r.RelTypeId == 13))
                           .Select(r => r.RefAliSpReq.shortdesc);
return string.Join("; ", query);

In .NET 3.5 you'd need to use this instead:

var query = c.TaskRelations.Where(r => r.TaskId == taskID 
                                       && r.RelTypeId == 13))
                           .Select(r => r.RefAliSpReq.shortdesc);
return string.Join("; ", query.ToArray());

Admittedly I can't tell whether that's actually what's making this slow or not - but it could well be, if there are a lot of strings.

As an aside, this is a terrible idea:

catch
{
    return String.Empty;
}

Catch specific exceptions instead - or in most cases, just let the exception propagate to the caller. At the very least you should log the exception so you know what's going wrong.

Jon Skeet
+1  A: 

All of your functions are calling the same piece of code with a different parameter:

try
{
    using (TaskCardContext.TaskMaintenanceDataDataContext dc = new TaskCardContext.TaskMaintenanceDataDataContext())
    {
        string aliSpReqs = String.Empty;

        foreach (var item in dc.TaskRelations.Where(tableRaletions => tableRaletions.TaskId == taskID && tableRaletions.RelTypeId == 13))
        {
            aliSpReqs += item.RefAliSpReq.shortdesc + "; ";
        }
        return aliSpReqs.Substring(0, aliSpReqs.Length - 2);
    }
}
catch
{
    return String.Empty;
}

So lets make a function out of it:

private static string GetData(int taskID, int typeID)
{
    try
    {
        using (TaskCardContext.TaskMaintenanceDataDataContext dc = new TaskCardContext.TaskMaintenanceDataDataContext())
        {
            //This was taken from Jons answer!!
            var query = c.TaskRelations.Where(r => r.TaskId == taskID 
                                              && r.RelTypeId == typeID))
                                       .Select(r => r.RefAliSpReq.shortdesc);
            return string.Join("; ", query.ToArray());
        }
    }
    catch
    {
        return String.Empty;
    }
}

Now you can call this function from all your other functions like:

public static string GetMaintData(int taskID)
{
    return GetData(taskID, 12);
}

So this makes your code much shorter. For a performance boost you should take Jons answer and do the concatenation of your string at last and not at every step by using +=, cause this is very bad.

Oliver