public List <E> GetAllWithCriteria(CriteriaBuilder criteria) { List <E> listObjects = new List <E>(); Open(); String sqlQuery = QueryGenerator <E> .SelectQuery(tableMapping, criteria.Query(), criteria.GroupBy(), criteria.Having(), criteria.OrederBy(), criteria.Limit(), criteria.Distinct()); SQLConsole.WriteLine(sqlQuery); Cursor cursor = databaseManager.Select(sqlQuery); try { for (cursor.MoveToNext(); !cursor.IsAfterLast(); cursor.MoveToNext()) { E obj = CursorToEntity(cursor); listObjects.Add(obj); } } catch (Exception e) { SQLConsole.WriteLine(e.StackTrace); } finally { try { cursor.Close(); } catch (Exception e) { SQLConsole.WriteLine(e.StackTrace); } Close(); } return(listObjects); }
public E GetWithCriteria(CriteriaBuilder criteria) { List <E> listObjects = GetAllWithCriteria(criteria); if (listObjects.Count > 0) { return(listObjects[0]); } else { return(null); } }
public CriteriaBuilder Or(CriteriaBuilder expression) { whereQuery = "(" + whereQuery + ") OR (" + expression.Query() + ")"; return(this); }