Commit in nhibernate

Monday, June 30, 2014

I created simple test for NHibernate but it not ok. Does anybody know this trouble below.



identifier of an instance of PosDAL.Users altered from 4 (System.Int32) to 0 (System.Int32)



http://ift.tt/1qd7M79 - I don't have enough reputation for upload image.


I'm using Sql Server 2008. Users table in db with Id is primary key and auto increase 1. In db, I add simple row like: username, email, fullname, ....etc by hands. But It's not working. I deleted that row, the program run normal.


My function in BussinessLogic layer:



public bool CheckLogin(string sUsername, string sEnCodePassw)
{
using(ISession session = SessionFactory.OpenSession())
using (ITransaction tx = session.BeginTransaction())
{
IList oUser =
session
.CreateSQLQuery("SELECT * FROM USERS WHERE U_USERNAME = ?")
.AddEntity(typeof(Users))
.SetString(0, sUsername)
.List();
tx.Commit();
return false;
}
}






http://ift.tt/1pRM2eY