Example #1
0
 /// <summary>
 /// The Dynamic Query properties.
 /// </summary>
 /// <param name="query">The esDynamicQuery's properties.</param>
 public DynamicQueryProps(tgDynamicQuery query)
 {
     this.dynamicQuery = query;
 }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        private void AssignProviderMetadata(tgDynamicQuerySerializable query, List <tgDynamicQuerySerializable> beenThere)
        {
            if (beenThere.Contains(query))
            {
                return;
            }

            beenThere.Add(query);

            tgDynamicQuery theQuery = query as tgDynamicQuery;
            IDynamicQuerySerializableInternal iQuery = query as IDynamicQuerySerializableInternal;

            if (theQuery != null)
            {
                tgConnection conn = theQuery.tg2.Connection;

                if (iQuery.ProviderMetadata == null)
                {
                    tgProviderSpecificMetadata 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 (tgColumnMetadata col in (tgColumnMetadataCollection)iQuery.Columns)
                {
                    tgQueryItem item = new tgQueryItem(this, col.Name, col.esType);
                    query.Select(item);
                }
            }
            else
            {
                List <tgQueryItem> columns = iQuery.SelectAllExcept;

                if (columns != null)
                {
                    foreach (tgColumnMetadata col in (tgColumnMetadataCollection)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;
                        }

                        tgExpression item = new tgQueryItem(this, col.Name, col.esType);
                        query.Select(item);
                    }
                }
            }

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

            if (iQuery.InternalSetOperations != null)
            {
                foreach (tgSetOperation setOperation in iQuery.InternalSetOperations)
                {
                    AssignProviderMetadata(setOperation.Query, beenThere);
                }
            }
        }