コード例 #1
0
ファイル: PatientContext.cs プロジェクト: ck0074451665/MB
 public List<PatientInfo> GetPatientInfo()
 {
     Mobao.M.Domain.IRepository<Patient> repoP = new Mobao.M.NHibernate.PatientRepository();
     Mobao.M.Domain.IRepository<Ward> repoW = new Mobao.M.NHibernate.WardRepository();
     Mobao.M.Domain.IRepository<PatientWardRelation> repoRelation =
         new Mobao.M.NHibernate.PatiendWardRelationRepository();
     var patientQuery = repoP.GetAll();
     var wQuery = repoW.GetAll();
     var pwRelation = repoRelation.GetAll();
     var query = from p in patientQuery
                 let sexName = p.Sex
                 let SexName = EnumHelper.GetDescription(sexName)
                 join pw in pwRelation on p.Id equals pw.PId
                 join w in wQuery on pw.WId equals w.Id
                 select new PatientInfo { PatientName = p.Name, SexName = SexName, WardName = w.Name };
     return query.ToList();
 }
コード例 #2
0
ファイル: TestNhibernate.cs プロジェクト: ck0074451665/MB
        public void TestAddRelation()
        {
            Mobao.M.Domain.IRepository<Patient> repoP = new Mobao.M.NHibernate.PatientRepository();
            Mobao.M.Domain.IRepository<Ward> repoW = new Mobao.M.NHibernate.WardRepository();
            Mobao.M.Domain.IRepository<PatientWardRelation> repoRelation =
                new Mobao.M.NHibernate.PatiendWardRelationRepository();

            var patientColl = repoP.GetAll().ToList();
            var wardColl = repoW.GetAll().ToList();
            foreach (var item in patientColl)
            {
                foreach (var item1 in wardColl)
                {
                    repoRelation.Add(new PatientWardRelation() { Id = Guid.NewGuid().ToString("N"), WId = item1.Id, PId = item.Id });
                }
            }
        }
コード例 #3
0
ファイル: PatientContext3.cs プロジェクト: ck0074451665/MB
 public PatientInfo GetPatientInfoEntity()
 {
     //  throw new ArgumentNullException("custome Test");
     Mobao.M.Domain.IRepository<Patient> repoP = new Mobao.M.NHibernate.PatientRepository();
     Mobao.M.Domain.IRepository<Ward> repoW = new Mobao.M.NHibernate.WardRepository();
     Mobao.M.Domain.IRepository<PatientWardRelation> repoRelation =
         new Mobao.M.NHibernate.PatiendWardRelationRepository();
     var patientQuery = repoP.GetAll();
     var wQuery = repoW.GetAll();
     var pwRelation = repoRelation.GetAll();
     var query = from p in patientQuery
                 let sexName = p.Sex
                 let SexName = EnumHelper.GetDescription(sexName)
                 join pw in pwRelation on p.Id equals pw.PId
                 join w in wQuery on pw.WId equals w.Id
                 select new PatientInfo { PatientName = p.Name, SexName = SexName, WardName = w.Name };
     return query.First();
     //return new List<PatientInfo>();
 }
コード例 #4
0
ファイル: TestNhibernate.cs プロジェクト: ck0074451665/MB
 public void TestLinqQuery()
 {
     Mobao.M.Domain.IRepository<Patient> repoP = new Mobao.M.NHibernate.PatientRepository();
     Mobao.M.Domain.IRepository<Ward> repoW = new Mobao.M.NHibernate.WardRepository();
     Mobao.M.Domain.IRepository<PatientWardRelation> repoRelation =
         new Mobao.M.NHibernate.PatiendWardRelationRepository();
     var patientQuery = repoP.GetAll();
     var wQuery = repoW.GetAll();
     var pwRelation = repoRelation.GetAll();
     var query = from p in patientQuery
                 let sexName = p.Sex
                 let SexName = EnumHelper.GetDescription(sexName)
                 join pw in pwRelation on p.Id equals pw.PId
                 join w in wQuery on pw.WId equals w.Id
                 select new { PatientId = p.Id, PatientName = p.Name, WardName = w.Name, SexName = SexName };
     foreach (var item in query)
     {
         Console.WriteLine(string.Format("病患:{0},病区:{1}。性别:{2}", item.PatientName, item.WardName, item.SexName));
     }
 }