Ejemplo n.º 1
0
        public string SqlString()
        {
            string    sql    = string.Empty;
            SqlEntity entity = GetSqlEntity();

            switch (this._type)
            {
            case SqlType.Query:
                sql = _adapter.Query(entity);
                break;

            case SqlType.Insert:
                sql = _adapter.Insert(_userKey, entity);
                break;

            case SqlType.Update:
                sql = _adapter.Update(entity);
                break;

            case SqlType.Delete:
                sql = _adapter.Delete(entity);
                break;

            default:
                break;
            }
            return(sql);
        }
Ejemplo n.º 2
0
        private SqlEntity GetSqlEntity()
        {
            SqlEntity entity = new SqlEntity();

            entity.Having     = GetForamtList(" ", "HAVING ", _havingConditions);
            entity.Grouping   = GetForamtList(", ", "GROUP BY ", _groupingList);
            entity.OrderBy    = GetForamtList(", ", "ORDER BY ", _sortList);
            entity.Conditions = GetForamtList("", "WHERE ", _conditions);
            entity.Parameter  = GetForamtList(", ", "", _parameters);
            entity.TableName  = GetTableName();
            entity.Selection  = GetSelection();
            return(entity);
        }
Ejemplo n.º 3
0
        public string QueryPage(int pageSize, int?pageNumber = null)
        {
            SqlEntity entity = GetSqlEntity();

            entity.PageSize = pageSize;
            if (pageNumber.HasValue)
            {
                if (_sortList.Count == 0 && _adapter is SqlserverAdapter)
                {
                    throw new Exception("Pagination requires the ORDER BY statement to be specified");
                }
                entity.PageNumber = pageNumber.Value;
            }
            return(_adapter.QueryPage(entity));
        }