public static Dictionary<int, string> GetLookupList(AdoDataConnection database, int deviceID, bool isOptional = true)
{
bool createdConnection = false;
try
{
createdConnection = CreateConnection(ref database);
Dictionary<int, string> phasorList = new Dictionary<int, string>();
if (isOptional)
phasorList.Add(0, "Select Phasor");
if (deviceID == 0)
return phasorList;
string query = database.ParameterizedQueryString("SELECT ID, Label FROM Phasor WHERE DeviceID = {0} ORDER BY SourceIndex", "deviceID");
DataTable phasorTable = database.Connection.RetrieveData(database.AdapterType, query, DefaultTimeout, deviceID);
foreach (DataRow row in phasorTable.Rows)
phasorList[row.ConvertField<int>("ID")] = row.Field<string>("Label");
return phasorList;
}
finally
{
if (createdConnection && database != null)
database.Dispose();
}
}