NHibernate is a small project (four)

xiaoxiao2021-03-06  41

Yesterday's question, solved, mood has always been now

Today, I perfected, my EntityControl class, plus two classes that returned entities and returning a single entity

Of course, I basically adopted a change to C # written by the flying eagle with VB.NET.

public

IList GetIntities (String Query)

{IList Lst; iSession s = sessionFactory.opension (); itrarsaction t = s.begintransaction (); lst = s.find (query); t.commit (); s.close (); return lst;}

public

Object GeTENTITY (Type Thetpe, Object ID)

{Object Obj; iSession s = sessionFactory.openSession (); itransaction t = s.begintransaction (); obj = s.load (THETYPE, ID); t.commit (); s.close (); return obj;}

In this case, we can continue to move.

For this class, there is an important way to handle the user's login. According to the knowledge I have, I can only write such a way, I don't know if there is a better way.

public

Users login

String

User,

String

PWD)

{Users Tmpuser; String HQL = "from guestbook.data.users as users where users.name = '" user "' and users.password = '" pwd "'"; ilist lst = control.genetitis (HQL); IF (lst.count! = 0) {tmpuser = (users) LST [0];} else {tmpuser = null;} Return Tmpuser;

Using HQL in query If there is a user who is satisfied, it returns a user class, and it is not returned.

转载请注明原文地址:https://www.9cbs.com/read-68742.html

New Post(0)