Exemplo n.º 1
0
        /// <summary>
        /// When passing type=0, it's never going to try to build a query - only fully formed query SQl will work.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="query"></param>
        /// <param name="parameters"></param>
        protected void ParseQuery(QueryType type, object query, IEnumerable <object> parameters)
        {
            IQuery outputQuery;

            if (query == null)
            {
                throw new IQMissingQueryException();
            }
            else if (query is IQuery)
            {
                ExpectNoParameters(parameters);
                if (type != 0 && ((IQuery)query).QueryType != type)
                {
                    throw new IQException("The query passed was not of type '" + type.ToString() + "' as required for this operation.");
                }
                outputQuery = (IQuery)query;
            }
            else if (type != 0)
            {
                outputQuery = ParseComplexQuery(type, query, parameters);
            }
            else if (query is string)
            {
                string queryString = (string)query;

                ParameterParser pp = new ParameterParser(queryString, parameters);
                CopyDbOptions(pp);

                outputQuery = new SqlQueryRaw(queryString, pp.Parameters);
            }
            else
            {
                throw new IQException("The type of object '" + query.GetType().ToString() + "' passed as a query isn't something I know how to handle.");
            }

            if (outputQuery == null)
            {
                throw new IQMissingQueryException();
            }

            if (outputQuery.QueryType == QueryType.Invalid)
            {
                throw new IQException("Couldn't make a valid query out of the mess you passed me. Check the SQL and the parameters.");
            }

            Query = outputQuery;
        }
Exemplo n.º 2
0
        public IQuery GetIQuery()
        {
            SqlQueryRaw query = new SqlQueryRaw(Query, Parameters);

            return(query);
        }
Exemplo n.º 3
0
 public IQuery GetIQuery()
 {
     SqlQueryRaw query = new SqlQueryRaw(Query, Parameters);
     return query;
 }
Exemplo n.º 4
0
 public IQuery Clone()
 {
     SqlQueryRaw query = new SqlQueryRaw(QuerySql, Parameters);
     return query;
 }
Exemplo n.º 5
0
        public IQuery Clone()
        {
            SqlQueryRaw query = new SqlQueryRaw(QuerySql, Parameters);

            return(query);
        }