Hello.
After query.List() my session is disconnected. Is it a bug?
my code:
Code:
public object GetById(Type typeToGet, int valueId)
{
_session.Reconnect();
object result;
try
{
NHibernate.IQuery query = _session.CreateQuery("");
switch (typeToGet.Name)
{
case "Customer":
query = _session.CreateQuery("from Customer as cus where cus.CustomerId = ?");
break;
case "Contract":
query = _session.CreateQuery("from Contract as con where con.ContractId = ?");
break;
}
query.SetInt32(0, valueId);
try
{
Console.WriteLine("1:" + _session.IsConnected);
result = query.List()[0];
Console.WriteLine("2:" + _session.IsConnected);
}
catch (ArgumentOutOfRangeException)
{
throw new NHibernate.ObjectNotFoundException(valueId, typeToGet);
}
}
finally
{
_session.Disconnect();
}
return result;
}
in the second try{} between Console.WriteLine("1:" + _session.IsConnected) and Console.WriteLine("2:" + _session.IsConnected) the connection is lost. Result is not empty and it appears no exception. How can it be? Can anyone help me?
regards
kesch