Ejemplo n.º 1
0
            public static IEnumerable <Employee> Page(int now, out int pages, int max = 10)
            {
                var q = new Entities.Employee();

                var u = q.Paged(sql: @"select e.HRE_FIRST_NAME, e.HRE_FAMILY_NAME, e.HRE_LAST_NAME, d.HRD_NAME, p.HRP_NAME, s.HRS_SUM, e.HRE_ID, e.ACL_USER_ID, u.ACLU_EMAIL from 
HR_EMPLOYEE e, HR_POSITION p, HR_DEPARTMENT d, HR_SALARY s, ACL_USER u
where p.HRP_ID = e.HRP_ID and d.HRD_ID = e.HRD_ID and s.HRD_ID = e.HRD_ID and s.HRP_ID = e.HRP_ID and u.ACL_USER_ID = e.ACL_USER_ID
", primaryKey: "HRE_FAMILY_NAME", pageSize: max, currentPage: now);

                pages = u.TotalPages;
                return((from d in (IEnumerable <dynamic>)u.Items select(Employee) FromEntity(d)).AsEnumerable <Employee>());
            }
Ejemplo n.º 2
0
            public static IEnumerable <Employee> PageSearchName(string nameStartsWith, string departmentStartsWith, int now, out int pages, int max = 10)
            {
                var    q    = new Entities.Employee();
                string sql  = @"select e.HRE_FIRST_NAME, e.HRE_FAMILY_NAME, e.HRE_LAST_NAME, d.HRD_NAME, p.HRP_NAME, s.HRS_SUM, e.HRE_ID, e.ACL_USER_ID, u.ACLU_EMAIL from 
HR_EMPLOYEE e, HR_POSITION p, HR_DEPARTMENT d, HR_SALARY s, ACL_USER u
where $inc1
 p.HRP_ID = e.HRP_ID and d.HRD_ID = e.HRD_ID  $inc2 and s.HRD_ID = e.HRD_ID and s.HRP_ID = e.HRP_ID and u.ACL_USER_ID = e.ACL_USER_ID
";
                string inc1 = "(e.HRE_FIRST_NAME like @0 or e.HRE_FAMILY_NAME like @0 or e.HRE_LAST_NAME like @0 ) and ";
                string inc2 = "and ( d.HRD_NAME like @1 )";

                sql = sql.Replace("$inc1", string.IsNullOrWhiteSpace(nameStartsWith) ? "" : inc1);
                sql = sql.Replace("$inc2", string.IsNullOrWhiteSpace(departmentStartsWith) ? "" : inc2);

                var u = q.Paged(sql: sql, primaryKey: "HRE_FAMILY_NAME", pageSize: max, currentPage: now, args: new object[] { nameStartsWith + "%", departmentStartsWith + "%" });


                pages = u.TotalPages;
                return((from d in (IEnumerable <dynamic>)u.Items select(Employee) FromEntity(d)).AsEnumerable <Employee>());
            }