NHinernate を使用してデータベースから特定のフィールドを取得しようとしています。問題は、ユーザー リストが null を返し続けることです。
私は何をしますか?これが私のコードです:
public IList<Users> GetHospitalStaff(string name) {
ISession session = NHibernateHelper.OpenSession();
ICriteria crt = session.CreateCriteria<Users>();
crt.Add(Restrictions.Eq("HospitalName", name));
crt.Add(!Restrictions.Eq("Role", "admin"));
IList<Users> users = crt.SetProjection(Projections.ProjectionList()
.Add(Projections.Property("Name"))
.Add(Projections.Property("Email"))
.Add(Projections.Property("Telephone"))
.Add(Projections.Property("DateOfBirth"))
.Add(Projections.Property("HospitalName"))
.Add(Projections.Property("Role")))
.SetResultTransformer(new NHibernate.Transform.AliasToBeanResultTransformer(typeof(Users)))
.List<Users>();
session.Close();
return users;
}