GSF.PhasorProtocols.UI.DataModels.Phasor.GetPhasor C# (CSharp) Method

GetPhasor() public static method

Retrieves Phasor information based on query string filter.
public static GetPhasor ( AdoDataConnection database, string whereClause ) : Phasor
database AdoDataConnection to connection to database.
whereClause string query string to filter data.
return Phasor
        public static Phasor GetPhasor(AdoDataConnection database, string whereClause)
        {
            bool createdConnection = false;

            try
            {
                createdConnection = CreateConnection(ref database);
                DataTable phasorTable = database.Connection.RetrieveData(database.AdapterType, "SELECT * FROM PhasorDetail " + whereClause);

                if (phasorTable.Rows.Count == 0)
                    return null;

                DataRow row = phasorTable.Rows[0];
                Phasor phasor = new Phasor
                    {
                        ID = row.ConvertField<int>("ID"),
                        DeviceID = row.ConvertField<int>("DeviceID"),
                        Label = row.Field<string>("Label"),
                        Type = row.Field<string>("Type"),
                        Phase = row.Field<string>("Phase"),
                        SourceIndex = row.ConvertField<int>("SourceIndex")
                    };

                return phasor;
            }
            finally
            {
                if (createdConnection && database != null)
                    database.Dispose();
            }
        }