Is it possible to get list after Session.Close as below?
var bundles = session.Linq<Bundle>();
session.Close();
var bs = bundles.ToList();
I get error, is there a different syntax for that?
Is it possible to get list after Session.Close as below?
var bundles = session.Linq<Bundle>();
session.Close();
var bs = bundles.ToList();
I get error, is there a different syntax for that?
You can't. Session is used for holding a connection to the data base. After you close the session, you cant get access to DB
It looks like you're going about this the wrong way. You need to use the UnitOfWork pattern. INSIDE you're unit of work is where you do things with your IQueriable. You can't just pass an IQueriable around because of it's dependence on an ISession. Perhaps your syntax will look like this:
public void DoSomethingWithData()
{
IList<Bundles> qbundles;
using (var uof = new UnitOfWork())
{
IQueriable<Bundle> bundles = uof.Repository<Bundle>().Query();
// just a litte example... replace with whatever
qbundles = bundles.Where(b => b.Qty == 5).ToList()
}
....
}
Here are some links that might get you started with this pattern:
http://nhforge.org/wikis/patternsandpractices/nhibernate-and-the-unit-of-work-pattern.aspx