Criterion emailEq = Restrictions.Eq(“email”,”[email protected]”);
Criteria crit = session.createCriteria(typeOf(User));
crit.add(emailEq);
User user = (User)Crit.uniqueResult();
是不是很简单?
上面是JAVA版本的写法
NHibernate.ICriteria crit = DALBase.SessionFactory.OpenedSession.CreateCriteria(typeof(InvoiceDomain.tbl_Member));
crit.Add(Expression.Eq(“UserName”, txtUserName.Text))
.Add(Expression.Eq(“UserPass”, txtPassword.Text));
InvoiceDomain.tbl_Member entMember = crit.UniqueResult() as InvoiceDomain.tbl_Member;
这是.NET的写法.不知道这里会不会有注入的可能呢?