i write a select method named slc in myclass. slc method return result from select of contact table. this method result is IorderdQueryable and i call this in my code-behind and i assign this result to a ListBox, i want to know how can i close my connection in my method ?does Iqueryable type close connetion automatically?
i use this code in slc method but it hase error
pubic cLass myclass
{
public IorderdQueryable
{
using(DataContext DataConextVar = new DataContext(cnclass.GetConnectionString("ConnectionString")))
{
var t=from b in DataConextVar.contactTbl select b;
return t;
}
please help me
}
Sam HobbsPosted Jan 8, 2011, 5:13 PM
IQueryable does not have a connection so it does not have a connection to close automatically.