//public IEnumerable<LookupName> GetNonMotoristAgeRangeLookups() //{ // var queryText = @"SELECT id AS key, nm_attr_cd AS code, nm_attr_tx AS name // FROM v_nm_age_rng // ORDER BY nm_attr_cd"; // IEnumerable<LookupKeyCodeAndName> results; // using (var conn = new OracleConnection(_connStr)) // { // results = conn.Query<LookupKeyCodeAndName>(queryText, new { }); // } // return DistinctLookupNames(results); //} //public IEnumerable<LookupName> GetCyclistAgeRangeLookups() //{ // return GetNonMotoristAgeRangeLookups(); //} //public IEnumerable<LookupName> GetPedestrianAgeRangeLookups() //{ // return GetNonMotoristAgeRangeLookups(); //} //public IEnumerable<LookupName> GetCrashTypeSimplified() //{ // var queryText = @"SELECT DISTINCT crash_attr_tx AS name // FROM v_crash_type_simplified // ORDER BY crash_attr_tx"; // IEnumerable<LookupName> results; // using (var conn = new OracleConnection(_connStr)) // { // results = conn.Query<LookupName>(queryText, new { }); // } // return results; //} //public IEnumerable<LookupName> GetCrashTypeDetailed() //{ // var queryText = @"SELECT DISTINCT crash_attr_tx AS name // FROM v_crash_type // ORDER BY crash_attr_tx"; // IEnumerable<LookupName> results; // using (var conn = new OracleConnection(_connStr)) // { // results = conn.Query<LookupName>(queryText, new { }); // } // return results; //} /// <summary> /// Utility method to convert an array of strings into an IEnumerable of LookupName. /// </summary> /// <param name="names">An array of strings.</param> /// <returns>An IEnumerable of LookupName.</returns> private IEnumerable <LookupName> GetLookupNames(string[] names) { var arr = new LookupName[names.Length]; for (var i = 0; i < names.Length; i++) { arr[i] = new LookupName() { name = names[i] }; } return(arr); }
/// <summary> /// Utility method to extract an IEnumerable of distinct LookupName from an /// IEnumerable of LookupKeyCodeAndName. /// </summary> /// <param name="origList">An IEnumerable of LookupKeyCodeAndName.</param> /// <returns>An IEnumerable of distinct LookupName.</returns> private IEnumerable <LookupName> DistinctLookupNames(IEnumerable <LookupKeyCodeAndName> origList) { var distinctList = new List <LookupName>(); foreach (var origItem in origList) { var lookupName = new LookupName { name = origItem.name }; if (!distinctList.Contains(lookupName)) { distinctList.Add(lookupName); } } return(distinctList); }