Nhibernate 2 (二) 查询
时间:2011-03-25 来源:eolande
Nhibernate 2 (一)配置+sqlserver+新增
public sealed class CatBal { …… public static string ShowCat() { ISession session = NHibernateHelper.GetCurrentSession(); using (ITransaction tx = session.BeginTransaction()) { IQuery query = session.CreateQuery("select c from Cat as c where c.Sex = :sex"); query.SetCharacter("sex", 'F'); StringBuilder sb = new StringBuilder(); foreach (Cat cat in query.Enumerable()) { sb.Append(cat.Name).Append(","); } tx.Commit(); return sb.ToString(); } } }
相关阅读 更多 +