/// <summary>
        ///
        /// </summary>
        private void AssignProviderMetadata(esDynamicQuerySerializable query, List <esDynamicQuerySerializable> beenThere)
        {
            if (beenThere.Contains(query))
            {
                return;
            }

            beenThere.Add(query);

            esDynamicQuery theQuery = query as esDynamicQuery;
            IDynamicQuerySerializableInternal iQuery = query as IDynamicQuerySerializableInternal;

            if (theQuery != null)
            {
                esConnection conn = theQuery.es2.Connection;

                if (iQuery.ProviderMetadata == null)
                {
                    esProviderSpecificMetadata providerMetadata = theQuery.Meta.GetProviderMetadata(conn.ProviderMetadataKey);
                    iQuery.DataID           = theQuery.Meta.DataID;
                    iQuery.Columns          = theQuery.Meta.Columns;
                    iQuery.ProviderMetadata = providerMetadata;
                }

                iQuery.Catalog = conn.Catalog;
                iQuery.Schema  = conn.Schema;
            }

            // This code is for proxies as they are unable to work with column and provider metadata
            // until serialized back to the server
            if (iQuery.SelectAll)
            {
                foreach (esColumnMetadata col in (esColumnMetadataCollection)iQuery.Columns)
                {
                    esQueryItem item = new esQueryItem(this, col.Name, col.esType);
                    query.Select(item);
                }
            }
            else
            {
                List <esQueryItem> columns = iQuery.SelectAllExcept;

                if (columns != null)
                {
                    foreach (esColumnMetadata col in (esColumnMetadataCollection)iQuery.Columns)
                    {
                        bool found = false;

                        for (int i = 0; i < columns.Count; i++)
                        {
                            if (col.Name == (string)columns[i])
                            {
                                found = true;
                                break;
                            }
                        }

                        if (found)
                        {
                            continue;
                        }

                        esExpression item = new esQueryItem(this, col.Name, col.esType);
                        query.Select(item);
                    }
                }
            }

            foreach (esDynamicQuerySerializable subQuery in iQuery.queries.Values)
            {
                AssignProviderMetadata(subQuery, beenThere);
            }

            if (iQuery.InternalSetOperations != null)
            {
                foreach (esSetOperation setOperation in iQuery.InternalSetOperations)
                {
                    AssignProviderMetadata(setOperation.Query, beenThere);
                }
            }
        }
 /// <summary>
 /// The Dynamic Query properties.
 /// </summary>
 /// <param name="query">The esDynamicQuery's properties.</param>
 public DynamicQueryProps(esDynamicQuery query)
 {
     this.dynamicQuery = query;
 }
Ejemplo n.º 3
0
 public esOverClause(esDynamicQuery query) => _query = query;