Framework Demo

This demo, based on SqlServer, is meant to show the versatility of the WYSE framework and the freedom that goes wit it. Combining .NET with SQL to create something that is more and better than the sum of the two parts. The following are examples of how better database interaction could take shape, but should not be considered as 'this is how you should do it'. WYSE is built to offer the freedom to do it the way you want. The idea is to be able to code without having to make code quality damaging compromises.

...and since code speaks louder than words demo code (stack trace) and database results are shown in a developer-tools-like panel as you interact with the server.

Advanced Language Features

The framework supports several ways of building queries and also facilitates dynamic SQL statements decoration. The latter enables to statements to be modified, which in turn offers the possibility to neatly encapsulate query building code centrally.

Building on the previous example featuring custom Selects... The following examples feature a shared/generic repository base that implements basic CRUD operations.

This repository base uses a centralized custom QueryBackbone that can decorate a query in a way that paging is added.

The small window you are using greatly diminishes your demo experience. Please consider viewing using a larger window.

Behind The Scenes Explanation

This is where you get to see what's happening behind the scenes when you interact with the site on the left side.

The view consists of three (collapsible) parts...

1. Full Code, Queries, And Results

The server handles the web requests that are the result of you interacting with the site.
In doing so, the demo backend code is executed which in turn uses WYSE.

The relevant/notable methods taking part in that process are shown in the first vertical tab.
Basically you are seeing a (partial) stack trace.
It is tree structure of which the nodes are collapsible/expandable for your browsing convenience.

The leaves of the STACK TRACE TREE are where interaction with the database takes place.
That is generally where you will find the generated SQL statements and the JSON of the converted database results.

2. Queries And Results Only

A filtered list of entries where only the database queries and results are shown.

3. API Results

If applicable: this shows the JSON of the call to the server as if it had been an API call.

  • Trace Entries: 2
      ...Framework.Controllers.HomeController.UpdateCustomerUsingSecurityDecoration:
      [HttpGet]
      public async Task<ViewResult> UpdateCustomerUsingSecurityDecoration()
      {
          var traceTree = _traceTreesRepository.Record();
          traceTree.RecordCodeMethodExecution(MethodBase.GetCurrentMethod());
      
          var customer = new Customer(
              _customer1Id,
              "John Doe: Updated",
              _division1Id,
              new Address(id: new Guid("22222222-2222-2222-2222-222222222222"), "Home town"),
              billingAddress: null);
      
          var result = await _customerService.UpdateCustomerUsingSecurityDecoration(
              customer,
              _user2Id,  /* User with Write rights for customer */
              traceTree);
      
          return CreateView(traceTree, result);
      }
    • Trace Entries: 2
        ...Framework.Services.CustomerService.UpdateCustomerUsingSecurityDecoration:
        public async Task<bool> UpdateCustomerUsingSecurityDecoration(
            Customer customer,
            Guid userId,
            TraceTree parentTraceTree)
        {
            var traceTree = parentTraceTree.AddChild();
            traceTree.RecordCodeMethodExecution(MethodBase.GetCurrentMethod());
        
            var customerTable = new CustomerTable();
            var update = /*WYSE*/UpdateBuilder.BuildByKey(customerTable, customer);
        
            var securityDecorator = new /*WYSE*/SecurityDecorator(
                new PrincipalTable(),  /* Users and groups the users can be member of */
                new PrincipalMembershipTable(),  /* Users/groups membership */
                membershipCteName: "Membership");  // If omitted default a generated Guid-name
        
            // Decorate the original Update in such a way that only if 'userId'
            // has the necessary Write rights the update takes place.
            var decoratedUpdate = securityDecorator.Decorate(update, userId);
        
            var result = await _sqlExecuter.ExecuteNonQueryWithRollbackAsync(
                decoratedUpdate,
                traceTree);
        
            return result == 1;
        }
      • Trace Entries: 2
          ...Framework.DataSpace.Access.SqlExecuter.ExecuteNonQueryWithRollbackAsync:
          public async Task<int> ExecuteNonQueryWithRollbackAsync(
              /*WYSE*/IExecutable executable,
              TraceTree parentTraceTree)
          {
              var traceTree = parentTraceTree.AddChild();
              traceTree.RecordCodeMethodExecution(MethodBase.GetCurrentMethod());
          
              using SqlConnection connection = _connectionFactory.Create();
              connection.Open();
              using var transaction = connection.BeginTransaction();
          
              // Aliases and parameter names can be given custom values.
              // If omitted, unique identifer values are supplied
              // In the case of this Demo, these generated values are overwritten,
              // based on the current render settings, with more legible values.
              // WYSE supports several kinds of Resetting/renaming.
              ResetIdentifiers(executable);
          
              using SqlCommand command = connection.CreateCommand()
                  // A WYSE Render context determines certain (overridable) render settings.
                  // Here the context is SqlServer. More SQL flavors are supported.
                  // A WYSE render builder is used for stringifying
                  // the strongly typed SQL statements.
                  /*WYSE*/.For(executable, _renderContextFactory.Create(), _createRenderBuilder);
              command.Transaction = transaction;
          
              try
              {
                  var result = await command.ExecuteNonQueryAsync();
          
                  traceTree.RecordDbCommandExecutionSuccess(
                      command.CommandText,
                      command.Parameters.ToDictionary(),
                      result);
          
                  transaction.Rollback();
          
                  return result;
              }
              catch (Exception exception)
              {
                  traceTree.RecordDbCommandExecutionFailure(
                      command.CommandText,
                      command.Parameters.ToDictionary(),
                      exception);
          
                  return -1;
              }
          }

          Command Parameters:

          @PrincipalId : 22222222-2222-2222-2222-222222222222

          Command Text:

          WITH [Membership] ([PrincipalId], [MemberOfPrincipalId])
          AS
          (
              SELECT
                  [56154_FrameworkDemoSystems_dbo_PrincipalMembership_1].[PrincipalId] [56154_FrameworkDemoSystems_dbo_PrincipalMembership_PrincipalId_1],
                  [56154_FrameworkDemoSystems_dbo_PrincipalMembership_1].[MemberOfPrincipalId] [56154_FrameworkDemoSystems_dbo_PrincipalMembership_MemberOfPrincipalId_1]
              FROM [56154_FrameworkDemoSystems].[dbo].[PrincipalMembership] [56154_FrameworkDemoSystems_dbo_PrincipalMembership_1]
              UNION ALL
              SELECT
                  [56154_FrameworkDemoSystems_dbo_PrincipalMembership_1].[PrincipalId] [56154_FrameworkDemoSystems_dbo_PrincipalMembership_PrincipalId_1],
                  [_GuidMembershipCte_1].[MemberOfPrincipalId] [_GuidCteColumn_1]
              FROM [Membership] [_GuidMembershipCte_1]
              INNER JOIN [56154_FrameworkDemoSystems].[dbo].[PrincipalMembership] [56154_FrameworkDemoSystems_dbo_PrincipalMembership_1] ON ([_GuidMembershipCte_1].[PrincipalId] = [56154_FrameworkDemoSystems_dbo_PrincipalMembership_1].[MemberOfPrincipalId])
          )
          UPDATE [56154_FrameworkDemoCustomers_demo_Customer]
          SET [56154_FrameworkDemoCustomers_demo_Customer].[Created] = '2025-05-23 14:18:09.615',
              [56154_FrameworkDemoCustomers_demo_Customer].[LastModified] = '2025-05-23 14:18:09.615',
              [56154_FrameworkDemoCustomers_demo_Customer].[IsDeleted] = 0,
              [56154_FrameworkDemoCustomers_demo_Customer].[FullName] = 'John Doe: Updated',
              [56154_FrameworkDemoCustomers_demo_Customer].[DivisionId] = '11111111-1111-1111-1111-111111111111',
              [56154_FrameworkDemoCustomers_demo_Customer].[HomeAddressId] = '22222222-2222-2222-2222-222222222222',
              [56154_FrameworkDemoCustomers_demo_Customer].[BillingAddressId] = NULL
          FROM [56154_FrameworkDemoCustomers].[demo].[Customer] [56154_FrameworkDemoCustomers_demo_Customer]
          CROSS APPLY
          (
              SELECT TOP(1) 1 [_NumberConst_1]
              FROM [56154_FrameworkDemoSystems].[dbo].[Principal] [56154_FrameworkDemoSystems_dbo_Principal]
              LEFT JOIN [Membership] [_GuidMembershipCte_2] ON ([56154_FrameworkDemoSystems_dbo_Principal].[Id] = [_GuidMembershipCte_2].[MemberOfPrincipalId])
              INNER JOIN [56154_FrameworkDemoCustomers].[demo].[CustomerPrincipalRights] [56154_FrameworkDemoCustomers_demo_CustomerPrincipalRights] ON ([56154_FrameworkDemoSystems_dbo_Principal].[Id] = [56154_FrameworkDemoCustomers_demo_CustomerPrincipalRights].[PrincipalId])
              WHERE
              (
                  (
                      ([56154_FrameworkDemoSystems_dbo_Principal].[Id] = @PrincipalId)
                      OR
                      ([_GuidMembershipCte_2].[PrincipalId] = @PrincipalId)
                  )
                  AND
                  ([56154_FrameworkDemoCustomers_demo_CustomerPrincipalRights].[CustomerId] = [56154_FrameworkDemoCustomers_demo_Customer].[Id])
                  AND
                  (([56154_FrameworkDemoCustomers_demo_CustomerPrincipalRights].[RightType] & 2) = 2) /* Has 'Write' flag */
              )
          ) [_Select_3]
          WHERE ([56154_FrameworkDemoCustomers_demo_Customer].[Id] = '11111111-1111-1111-1111-111111111111')

Command Parameters:

@PrincipalId : 22222222-2222-2222-2222-222222222222

Command Text:

WITH [Membership] ([PrincipalId], [MemberOfPrincipalId])
AS
(
    SELECT
        [56154_FrameworkDemoSystems_dbo_PrincipalMembership_1].[PrincipalId] [56154_FrameworkDemoSystems_dbo_PrincipalMembership_PrincipalId_1],
        [56154_FrameworkDemoSystems_dbo_PrincipalMembership_1].[MemberOfPrincipalId] [56154_FrameworkDemoSystems_dbo_PrincipalMembership_MemberOfPrincipalId_1]
    FROM [56154_FrameworkDemoSystems].[dbo].[PrincipalMembership] [56154_FrameworkDemoSystems_dbo_PrincipalMembership_1]
    UNION ALL
    SELECT
        [56154_FrameworkDemoSystems_dbo_PrincipalMembership_1].[PrincipalId] [56154_FrameworkDemoSystems_dbo_PrincipalMembership_PrincipalId_1],
        [_GuidMembershipCte_1].[MemberOfPrincipalId] [_GuidCteColumn_1]
    FROM [Membership] [_GuidMembershipCte_1]
    INNER JOIN [56154_FrameworkDemoSystems].[dbo].[PrincipalMembership] [56154_FrameworkDemoSystems_dbo_PrincipalMembership_1] ON ([_GuidMembershipCte_1].[PrincipalId] = [56154_FrameworkDemoSystems_dbo_PrincipalMembership_1].[MemberOfPrincipalId])
)
UPDATE [56154_FrameworkDemoCustomers_demo_Customer]
SET [56154_FrameworkDemoCustomers_demo_Customer].[Created] = '2025-05-23 14:18:09.615',
    [56154_FrameworkDemoCustomers_demo_Customer].[LastModified] = '2025-05-23 14:18:09.615',
    [56154_FrameworkDemoCustomers_demo_Customer].[IsDeleted] = 0,
    [56154_FrameworkDemoCustomers_demo_Customer].[FullName] = 'John Doe: Updated',
    [56154_FrameworkDemoCustomers_demo_Customer].[DivisionId] = '11111111-1111-1111-1111-111111111111',
    [56154_FrameworkDemoCustomers_demo_Customer].[HomeAddressId] = '22222222-2222-2222-2222-222222222222',
    [56154_FrameworkDemoCustomers_demo_Customer].[BillingAddressId] = NULL
FROM [56154_FrameworkDemoCustomers].[demo].[Customer] [56154_FrameworkDemoCustomers_demo_Customer]
CROSS APPLY
(
    SELECT TOP(1) 1 [_NumberConst_1]
    FROM [56154_FrameworkDemoSystems].[dbo].[Principal] [56154_FrameworkDemoSystems_dbo_Principal]
    LEFT JOIN [Membership] [_GuidMembershipCte_2] ON ([56154_FrameworkDemoSystems_dbo_Principal].[Id] = [_GuidMembershipCte_2].[MemberOfPrincipalId])
    INNER JOIN [56154_FrameworkDemoCustomers].[demo].[CustomerPrincipalRights] [56154_FrameworkDemoCustomers_demo_CustomerPrincipalRights] ON ([56154_FrameworkDemoSystems_dbo_Principal].[Id] = [56154_FrameworkDemoCustomers_demo_CustomerPrincipalRights].[PrincipalId])
    WHERE
    (
        (
            ([56154_FrameworkDemoSystems_dbo_Principal].[Id] = @PrincipalId)
            OR
            ([_GuidMembershipCte_2].[PrincipalId] = @PrincipalId)
        )
        AND
        ([56154_FrameworkDemoCustomers_demo_CustomerPrincipalRights].[CustomerId] = [56154_FrameworkDemoCustomers_demo_Customer].[Id])
        AND
        (([56154_FrameworkDemoCustomers_demo_CustomerPrincipalRights].[RightType] & 2) = 2) /* Has 'Write' flag */
    )
) [_Select_3]
WHERE ([56154_FrameworkDemoCustomers_demo_Customer].[Id] = '11111111-1111-1111-1111-111111111111')