In the code sample below, will my data context connection stay open once the ListOfLists method is completed? Do I need to explicitly close it, or will it stay open and be available for other methods.
public static Dictionary<int, string > ListOfLists()
{
try
{
ListDataDataContext db = new ListDataDataContext(GetConnectionString("Master"));
return db.ListMatchingHeaders
.Select(r => new { r.ListRecNum, r.ListName })
.ToDictionary(t => t.ListRecNum, t => t.ListName);
}
catch (Exception)
{
MessageBox.Show("Could not connect to database, please check connection and try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
}