ActivEarth.DAO.GroupDAO.GetAllGroupsByName C# (CSharp) Method

GetAllGroupsByName() public static method

Retrieves all currently created Groups that have a name containing the given string.
public static GetAllGroupsByName ( string partialName ) : List
partialName string A string desired to be contained within the Group name
return List
        public static List<Group> GetAllGroupsByName(string partialName)
        {
            List<Group> namedGroups = new List<Group>();

            using (SqlConnection connection = ConnectionManager.GetConnection())
            {
                var data = new ActivEarthDataProvidersDataContext(connection);

                List<int> groupIds = (from g in data.GroupDataProviders
                                      where g.name.ToLower().Contains(partialName.ToLower())
                                      select g.id
                                      ).ToList();

                foreach (int groupId in groupIds)
                {
                    Group group = GetGroupFromGroupId(groupId);
                    namedGroups.Add(group);
                }

                return namedGroups;
            }
        }