This class is used by EntitySpaces to issue loosely coupled calls to the actual EntitySpaces data provider as defined in the web.config or app.config file.
Beispiel #1
0
        /// <summary>
        /// Execute the query and return a single value.
        /// </summary>
        /// <returns>The value</returns>
        virtual public T ExecuteScalar <T>()
        {
            FixupSerializedQueries();

            tgDataRequest request = new tgDataRequest();

            this.PopulateRequest(request);

            tgDataProvider provider = new tgDataProvider();
            tgDataResponse response = provider.ExecuteScalar(request, this.tg2.Connection.ProviderSignature);

            return((T)response.Scalar);
        }
Beispiel #2
0
        /// <summary>
        /// Execute the Query and loads your BusinessEntity.
        /// If you need to be notified that this is being called
        /// override BusinessEntity.Query.OnLoadEvent().
        /// </summary>
        /// <remarks>
        /// The default conjunction is AND.
        /// You can change the default conjunction this way:
        /// <code>
        /// emps.Query.es.DefaultConjunction = tgConjunction.Or;
        /// </code>
        /// </remarks>
        /// <returns>True if at least one record was loaded</returns>
        virtual public bool Load()
        {
            bool loaded = false;

            DataTable table = null;

            FixupSerializedQueries();

            tgDataRequest request = new tgDataRequest();

            this.PopulateRequest(request);

            tgDataProvider provider = new tgDataProvider();
            tgDataResponse response = provider.esLoadDataTable(request, this.tg2.Connection.ProviderSignature);

            table = response.Table;

            if (prefetchMaps != null)
            {
                foreach (tgPrefetchMap map in prefetchMaps)
                {
                    // Give our Prefetch Queries the proper connection strings
                    if (!map.Query.tg2.HasConnection)
                    {
                        string generatedName = this.GetConnectionName();

                        if (generatedName != null)
                        {
                            // Use the connection name typed into the generated master when they
                            // generated the code
                            map.Query.tg2.Connection.Name = generatedName;
                        }
                        else
                        {
                            // Use the connection from the Collection/Entity at the time they
                            // call Load()
                            map.Query.tg2.Connection.Name = this.connection.Name;
                        }
                    }

                    map.Table = map.Query.LoadDataTable();
                }
            }

            if (this.OnLoadDelegate != null)
            {
                loaded = OnLoadDelegate(this, table);
            }

            return(loaded);
        }
Beispiel #3
0
        /// <summary>
        /// This merely parses and returns the SQL Syntax, no SQL is executed.
        /// </summary>
        /// <remarks>
        /// The default conjunction is AND.
        /// You can change the default conjunction this way:
        /// <code>
        /// emps.Query.es.DefaultConjunction = tgConjunction.Or;
        /// </code>
        /// </remarks>
        /// <returns>The SQL Syntax, the same as query.es.LastQuery when a query is executed.</returns>
        virtual public string Parse()
        {
            FixupSerializedQueries();

            tgDataRequest request = new tgDataRequest();

            this.PopulateRequest(request);
            request.QueryType = tgQueryType.DynamicQueryParseOnly;

            tgDataProvider provider = new tgDataProvider();
            tgDataResponse response = provider.esLoadDataTable(request, this.tg2.Connection.ProviderSignature);

            return(response.LastQuery);
        }
Beispiel #4
0
        /// <summary>
        /// Execute the Query and load a DataTable.
        /// </summary>
        /// <returns>A DataTable containing the loaded records.</returns>
        virtual public DataTable LoadDataTable()
        {
            DataTable table = null;

            FixupSerializedQueries();

            tgDataRequest request = new tgDataRequest();

            this.PopulateRequest(request);

            tgDataProvider provider = new tgDataProvider();
            tgDataResponse response = provider.esLoadDataTable(request, this.tg2.Connection.ProviderSignature);

            table = response.Table;

            return(table);
        }