When i use NHibernate to update or save(insert) entity,i find the code (session.Flush())doesn't work and no error message,and the program is end in there(not breakdown,function is end in there). But i was success to use it insert entity and i didn't modify any code. I'm confused,pls help me. The code is there:
ISession session = SessionBuilder.SessionFactory.OpenSession();
switch (editType)
{
case 'S': {
try
{
//new info set default;
cs.ID = 132;
clc.ID = cs.ID;
cmc.ID = cs.ID;
cs.COEFFICIENT_ID = 0;
cs.IF_ASSOCIATION = 'N';
cs.COST_PRICE = 0.0f;
session.Save(cs);
session.Save(clc);
session.Save(cmc);
session.Flush();//<<--if i set a breakpoint in there,
//and next step the whole function will end,no catch no finally
//no return,the application seem never run this function.
//and the application continues to run normal.
flg = true;
}catch (Exception e)
{
flg = false;
throw e;
}
finally
{
session.Close();
}
break;
}
case 'E': {
try
{
session.Update(cs);
session.Update(clc);
session.Update(cmc);
session.Flush();//<<--if i set a breakpoint in there,
//and next step the whole function will end,no catch no finally
//no return,the application seem never run this function.
//and the application continues to run normal.
flg = true;
}catch(Exception e)
{
flg = false;
throw e;
}
finally
{
session.Close();
}
break; }
default: { return false; }
}
return flg;
}