Ticket T622683
Visible to All Users

Query Builder - Limit the list of available Stored Procedures, Tables, or Views

created 7 years ago

Hello

We have given our customers the ability to create and modify their own Dashboards. Our data structure is quite complex and the customer can set who can see individual records . To overcome this we have created a number of Stored Procedures for use by the customers where we set the user credentials as the page is loaded. We have, with your assistance, removed the option for the customers to use the Query Builder feature when working with Data Sources. All of the necessary Stored Procedures are prefixed with 'Dashboard_'.

Is it possible to limit the list of available Stored Procedures in the Dashboard Data Source Wizard window?

Cheers
James

Answers approved by DevExpress Support

created 7 years ago (modified 7 years ago)

Hello James,

To achieve your goal, create a custom DB schema provider by implementing the IDBSchemaProviderEx interface and return only required stored procedures by overriding the GetProcedures method. Refer to the How to: Customize a Data Store Schema for SQL Data Sources example for more details. To assign your custom DB schema provider to Web Dashboard, call the ASPxDashboard.SetDBSchemaProvider method.

Update:
If you want only to hide certain stored procedures, you can inherit a custom provider from the base DBSchemaProviderEx class. Then, override the GetProcedures function and call the base function to get the default list of stored procedures. You will be able to filter out unnecessary stored procedures from the list.

C#
public class CustomDBSchemaProvider : DBSchemaProviderEx { public override DBStoredProcedure[] GetProcedures(SqlDataConnection connection, params string[] procedureList) { var procedures = base.GetProcedures(connection, procedureList); if (procedureList.Length == 0) // procedureList is empty if schema is loaded by the query builder return procedures.Take(3).ToArray(); else // before data loading dashboard requests schema only for the used procedures return procedures; } }
    Show previous comments (3)
    Sergi (DevExpress) 7 years ago

      Hello James,

      The Take and Where methods are the standard LINQ methods that can be applied to a collection of objects. For instance, I suggest that you review the How do I append a 'where' clause using VB.NET and LINQ? article to learn how to use the Where method in VB.NET.

      A A
      Ansarada TriLine GRC 7 years ago

        Thanks for that. The LINQ perspective was not clear from the error message.
        I modified the example as such:

        Visual Basic
        Private Class CustomDBSchemaProvider Inherits DBSchemaProviderEx Public Overrides Function GetProcedures(ByVal connection As SqlDataConnection, ParamArray ByVal procedureList() As String) As DBStoredProcedure() Dim procedures = MyBase.GetProcedures(connection, procedureList) If procedureList.Length = 0 Then 'procedureList is empty if schema is loaded by the query builder Return procedures.Where(Function(d) d.Name.StartsWith("Dashboard_")).ToArray() Else 'before data loading dashboard requests schema only for the used procedures Return procedures End If End Function End Class

        Cheers
        James

        Sergi (DevExpress) 7 years ago

          I am happy to hear that the problem has been resolved.  Thank you for letting us know of your progress.
          Please feel free to contact us if you have any difficulties.  We will be happy to assist you.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.