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.CreateCustomerUsingSecurityDecoration:
      [HttpGet]
      public async Task<ViewResult> CreateCustomerUsingSecurityDecoration()
      {
          var traceTree = _traceTreesRepository.Record();
          traceTree.RecordCodeMethodExecution(MethodBase.GetCurrentMethod());
      
          var newCustomer = new Customer(
              Guid.NewGuid(),
              "John Doe",
              _division1Id,
              new Address(id: new Guid("22222222-2222-2222-2222-222222222222"), "Home town"),
              billingAddress: null);
      
          var result = await _customerService.CreateCustomerUsingSecurityDecoration(
              newCustomer,
              _user3Id,  /* User (Principal) receiving rights for the new Customer row */
              traceTree);
      
          return CreateView(traceTree, result);
      }
    • Trace Entries: 2
        ...Framework.Services.CustomerService.CreateCustomerUsingSecurityDecoration:
        public async Task<bool> CreateCustomerUsingSecurityDecoration(
            Customer customer,
            Guid principalId,
            TraceTree parentTraceTree)
        {
            var traceTree = parentTraceTree.AddChild();
            traceTree.RecordCodeMethodExecution(MethodBase.GetCurrentMethod());
        
            var customerTable = new CustomerTable();
            var insertInto = /*WYSE*/InsertIntoBuilder.Build(customerTable, customer);
        
            var securityDecorator = new /*WYSE*/SecurityDecorator(
                new PrincipalTable(),  /* Users and groups the users can be member of */
                new PrincipalMembershipTable());  // Users/groups membership
        
            // Create a script with two inserts: one for the customer, one new customer rights entry
            // The principal gets read/write/delete rights on the newly created customer.
            // Instead of the principal Id also a group the principal is member of can be used
            /*WYSE*/Script decoratedInsertInto = securityDecorator.CreateInsertScript(
                insertInto,
                principalId);
        
            var result = await _sqlExecuter.ExecuteNonQueryWithRollbackAsync(
                decoratedInsertInto,
                traceTree);
        
            return result == 2;
        }
      • 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 Text:

          INSERT INTO [56154_FrameworkDemoCustomers].[demo].[Customer]
          ([Id], [Created], [LastModified], [IsDeleted], [FullName], [DivisionId], [HomeAddressId], [BillingAddressId])
          VALUES ('1b74022a-ad4a-4739-8c1f-10badf4c0b61', '2025-05-23 15:32:19.022', '2025-05-23 15:32:19.022', 0, 'John Doe', '11111111-1111-1111-1111-111111111111', '22222222-2222-2222-2222-222222222222', NULL);
          
          INSERT INTO [56154_FrameworkDemoCustomers].[demo].[CustomerPrincipalRights]
          ([CustomerId], [PrincipalId], [RightType])
          VALUES ('1b74022a-ad4a-4739-8c1f-10badf4c0b61', '33333333-3333-3333-3333-333333333333', 7);

Command Text:

INSERT INTO [56154_FrameworkDemoCustomers].[demo].[Customer]
([Id], [Created], [LastModified], [IsDeleted], [FullName], [DivisionId], [HomeAddressId], [BillingAddressId])
VALUES ('1b74022a-ad4a-4739-8c1f-10badf4c0b61', '2025-05-23 15:32:19.022', '2025-05-23 15:32:19.022', 0, 'John Doe', '11111111-1111-1111-1111-111111111111', '22222222-2222-2222-2222-222222222222', NULL);

INSERT INTO [56154_FrameworkDemoCustomers].[demo].[CustomerPrincipalRights]
([CustomerId], [PrincipalId], [RightType])
VALUES ('1b74022a-ad4a-4739-8c1f-10badf4c0b61', '33333333-3333-3333-3333-333333333333', 7);