views:

34

answers:

0

Hi I have a strange problem with retrieving data from database. In my form I have a combobox. The combobox contains couple of items - department's name. Everytime I choose an item from combobox I connect to database and fire this

public List<User> SelectAllSecurityUsersByDepartment(string departmentId)
    {
        var result = DBConnection._DB.Selectallsecurityusersbydeparment(departmentId);
        if (result != null)
        {
            return result.Select(u => (User)EntityTranslator.ToEntity(u)).ToList();
        }
        else
        {
            return null;
        }
    }

This method download all users which work in given department. The problem is that I got an error

query results can't be enumerated more than once

if only I choose an item from combobox for a second time. I mean if I connect to database for the first time (choose an item from combobox for the first time) everything is OK, however if I try do this again I get error mentioned above. What might be the problem?