示例#1
0
        public IList <PersonWithSkillsCount> GetPersonRowsHavingMoreThanOneSkill()
        {
            using (var tran = _session.BeginTransaction())
            {
                try
                {
                    PersonSkills          skills = null;
                    Person                person = null;
                    PersonWithSkillsCount row    = null;

                    var res = _session.QueryOver(() => person)
                              .JoinAlias(() => person.SkillsList, () => skills)
                              .SelectList(list => list
                                          .SelectGroup(() => person.Id).WithAlias(() => row.PersonId)
                                          .SelectGroup(() => person.FName).WithAlias(() => row.Firstname)
                                          .SelectGroup(() => person.LName).WithAlias(() => row.Lastname)
                                          .SelectCount(() => skills.Person).WithAlias(() => row.SkillsCount))
                              .Where(Restrictions.Gt(Projections.Count(Projections.Property(() => skills.Person)), 1))
                              .TransformUsing(Transformers.AliasToBean <PersonWithSkillsCount>())
                              .List <PersonWithSkillsCount>();

                    tran.Commit();
                    return(res);
                }
                catch (Exception ex)
                {
                    Logger.Logger.AddToLog("PersonRepository | AddPerson | {0}", ex);
                    tran.Rollback();
                    return(null);
                }
            }
        }
示例#2
0
        public IList <EmployeDetails> GetEmployeeDetails1()
        {
            using (var tran = _session.BeginTransaction())
            {
                try
                {
                    Employee       emp = null;
                    PersonSkills   skl = null;
                    EmployeDetails row = null;

                    return(_session.QueryOver(() => emp)
                           //.JoinAlias(() => pers.Id, () => emp)
                           .JoinAlias(() => emp.SkillsList, () => skl)
                           .SelectList(list => list
                                       .Select(() => emp.FName).WithAlias(() => row.Firstname)
                                       .Select(() => emp.LName).WithAlias(() => row.Lastname)
                                       .Select(() => emp.DateOfBirth).WithAlias(() => row.BirthDate)
                                       .Select(() => emp.Department).WithAlias(() => row.Department)
                                       .Select(() => emp.Role).WithAlias(() => row.Role)
                                       .Select(() => skl.Name).WithAlias(() => row.SkillName)
                                       .Select(() => skl.Level).WithAlias(() => row.SkillLevel))
                           .TransformUsing(Transformers.AliasToBean <EmployeDetails>())
                           .List <EmployeDetails>());
                }
                catch (Exception ex)
                {
                    Logger.Logger.AddToLog("PersonRepository | AddPerson | {0}", ex);
                    tran.Rollback();
                    return(null);
                }
            }
        }
示例#3
0
        public IList <Person> GetAllPersonsWithSkills()
        {
            using (var tran = _session.BeginTransaction())
            {
                try
                {
                    Person       person = null;
                    PersonSkills skills = null;

                    return(_session.QueryOver(() => person)
                           .JoinAlias(() => person.SkillsList, () => skills)
                           .TransformUsing(Transformers.DistinctRootEntity)
                           .List <Person>());
                }
                catch (Exception ex)
                {
                    Logger.Logger.AddToLog("PersonRepository | AddPerson | {0}", ex);
                    tran.Rollback();
                    return(null);
                }
            }
        }