1

I have a collection called dbUsers of type IQueryable

These are pulled from a linqtosql database context i.e.

IQueryable<Data.LinqToSQL.User> dbUsers = DBContext.Users

Calling ToList on this object:

IList<Data.LinqToSQL.User> users = dbUsers.ToList();

Results in an exception:

ExecuteReader requires an open and available Connection. The connection's current state is connecting.

What am I doing wrong here?

Cheers

iasksillyquestions
  • 5,558
  • 12
  • 53
  • 75

2 Answers2

2

see if this works for you:

IList<Data.LinqToSQL.User> users = (from u in DBContext.Users select u).ToList();

if not you might need to do something like:

DBContext context = new DBContext();
IList<Data.LinqToSQL.User> users = (from u in context.Users select u).ToList();
John Boker
  • 82,559
  • 17
  • 97
  • 130
1

I think this is a threading problem with the DataContext. I am getting similar problems. Check this question for more details.

Additionally read this and this.

Community
  • 1
  • 1
Matt Kocaj
  • 11,278
  • 6
  • 51
  • 79