Ejemplo n.º 1
0
        internal static QueryFactory CreateQueryFactory(XQuery xQuery)
        {
            QueryFactory factory = new QueryFactory(xQuery.Connection, xQuery.Compiler)
            {
                Logger = xQuery.Logger
            };

            return(factory);
        }
Ejemplo n.º 2
0
        public Query Query()
        {
            XQuery query = new XQuery(Connection, Compiler)
            {
                QueryFactory = this,

                Logger = Logger
            };

            return(query);
        }
Ejemplo n.º 3
0
        public override Query Clone()
        {
            XQuery query = new XQuery(Connection, Compiler)
            {
                Clauses = Clauses.Select(x => x.Clone()).ToList(),
                Logger  = Logger,

                QueryAlias = QueryAlias,
                IsDistinct = IsDistinct,
                Method     = Method,
                Includes   = Includes,
                Variables  = Variables
            };

            query.SetEngineScope(EngineScope);

            return(query);
        }
Ejemplo n.º 4
0
        internal static XQuery CastToXQuery(Query query, string method = null)
        {
            XQuery xQuery = query as XQuery;

            if (xQuery is null)
            {
                if (method == null)
                {
                    throw new InvalidOperationException(
                              $"Execution methods can only be used with `{nameof(XQuery)}` instances, " +
                              $"consider using the `{nameof(QueryFactory)}.{nameof(QueryFactory.Query)}()` to create executable queries, " +
                              $"check https://sqlkata.com/docs/execution/setup#xquery-class for more info");
                }

                throw new InvalidOperationException($"The method '{method}()' can only be used with `{nameof(XQuery)}` instances, " +
                                                    $"consider using the `{nameof(QueryFactory)}.{nameof(QueryFactory.Query)}()` to create executable queries, " +
                                                    $"check https://sqlkata.com/docs/execution/setup#xquery-class for more info");
            }

            return(xQuery);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///  Create an XQuery instance from a regular Query
        /// </summary>
        /// <param name="query">
        /// </param>
        /// <returns>
        /// </returns>
        public Query FromQuery(Query query)
        {
            XQuery xQuery = new XQuery(Connection, Compiler)
            {
                QueryFactory = this,

                Clauses = query.Clauses.Select(x => x.Clone()).ToList()
            };

            xQuery.SetParent(query.Parent);
            xQuery.QueryAlias = query.QueryAlias;
            xQuery.IsDistinct = query.IsDistinct;
            xQuery.Method     = query.Method;
            xQuery.Includes   = query.Includes;
            xQuery.Variables  = query.Variables;

            xQuery.SetEngineScope(query.EngineScope);

            xQuery.Logger = Logger;

            return(xQuery);
        }