Beispiel #1
0
        /// <summary>
        /// Renders the JOIN for a query.
        /// </summary>
        public static string Join(Joinable pJoin)
        {
            if (pJoin.Type == eJOIN.NONE)
            {
                throw new ModelException("JOIN type not set for query.");
            }

            string type = pJoin.Type.ToString().Replace("_", " ");
            string on = ((Conditions)pJoin.Where).Root.Render();

            IEnumerable<string> tables = pJoin.JoinTables.Select(pJoinTable => string.Format("`{0}`",pJoinTable.Table));

            return string.Format("{0} JOIN ({1}) ON {2}", type, string.Join(_COMMA, tables), on);
        }
Beispiel #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public QueryBuilder(eTYPE pType, Model pModel)
        {
            _where = new Conditions(this);
            _type = pType;
            _model = pModel;
            Joins = new Joinable(this);

            _parameters = new Parameters(this, pModel);
            _variables = new Parameters(this, pModel);

            _fields = new Fields(this);
            _duplicate = new Fields(this);
            _groups = new Fields(this);

            Order = new List<KeyValuePair<eDIR, string>>();
            Limit = 0;
            Offset = 0;
            Locked = false;
        }