public int Employees_GetCount(string serializedQuery) { EmployeesQuery query = EmployeesQuery.SerializeHelper.FromXml( serializedQuery, typeof(EmployeesQuery), AllKnownTypes) as EmployeesQuery; return(query.ExecuteScalar <int>()); }
static private void GetTheCount() { EmployeesQuery q = new EmployeesQuery(); q.Select(q.Count()); q.Where(q.LastName.Like("%a")); int count = q.ExecuteScalar <int>(); }
private void EnsureData() { EmployeesQuery q = new EmployeesQuery(); q.tg.CountAll = true; int i = q.ExecuteScalar <int>(); if (i == 0) { Employees emp = new Employees(); emp.FirstName = "Mike"; emp.LastName = "Griffin"; emp.Save(); } }
public jsResponse <EmployeesCollection, Employees> Employees_Pager(jsPagerRequest request) { jsResponse <EmployeesCollection, Employees> response = new jsResponse <EmployeesCollection, Employees>(); try { // We send the the same data they sent us back response.pagerRequest = request; EmployeesQuery q = null; if (response.pagerRequest.getTotalRows == true) { // Get the total count of rows in the Employee table q = new EmployeesQuery(); q.es.CountAll = true; response.pagerRequest.totalRows = q.ExecuteScalar <int>(); } q = new EmployeesQuery(); q.Select(q.EmployeeID, q.FirstName, q.LastName, q.Title); if (request.sortCriteria != null && request.sortCriteria.Length > 0) { for (int i = 0; i < request.sortCriteria.Length; i++) { jsPagerSortCriteria sort = request.sortCriteria[i]; q.OrderBy(sort.column, sort.direction.ToUpper().StartsWith("A") ? esOrderByDirection.Ascending : esOrderByDirection.Descending); } } else { // Default sort if none is specified q.OrderBy(q.EmployeeID.Ascending); } if (request.filterCriteria != null && request.filterCriteria.Length > 0) { esComparison comp = null; for (int i = 0; i < request.filterCriteria.Length; i++) { jsPagerFilterCriteria filter = request.filterCriteria[i]; comp = q.ManualWhere(filter.column, filter.operation, filter.criteria1, filter.criteria2, filter.conjuction); } q.Where(comp); } // Set the paging indicators up q.es.PageNumber = request.pageNumber; q.es.PageSize = request.pageSize; EmployeesCollection coll = new EmployeesCollection(); coll.Load(q); response.pagerRequest.getTotalRows = false; response.collection = coll; } catch (Exception ex) { response.exception = ex.Message; } return(response); }