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.GetCustomer:
      [HttpGet]
      public async Task<ViewResult> GetCustomer(Guid id)
      {
          var traceTree = _traceTreesRepository.Record();
          traceTree.RecordCodeMethodExecution(MethodBase.GetCurrentMethod());
      
          var result = await _customerService.GetCustomerResult(id, traceTree);
      
          return CreateView(traceTree, result);
      }
    • Trace Entries: 5
        ...Framework.Services.CustomerService.GetCustomerResult:
        public async Task<Customer> GetCustomerResult(Guid id, TraceTree parentTraceTree)
        {
            var traceTree = parentTraceTree.AddChild();
            traceTree.RecordCodeMethodExecution(MethodBase.GetCurrentMethod());
        
            // Inherit from WYSE Select
            var customerSubselect = new CustomerSubselect(traceTree, id: id);
        
            Select select = new /*WYSE*/Select()
                .Everything()  // Effectively an '*', but explicit
                .From(customerSubselect);
        
            return await GetItem(select, customerSubselect.Convert, traceTree);
        }
      • Trace Entries: 1
          ...Framework.DataSpace.Queries.ItemSubselectBase ctor:
          /*
           * ItemSubselectBase is the Framework Demo base class for all subselects used in
           * repositories and other dynamic query building.
           * This class inherits from WYSE's convertable subselect that enables query result row 
           * conversion (extending DbDataReader) and (Hierarchical) Object Relational Mapping.
           * Usage examples (different overloads):
           * - var select = new AddressSelect()  // Gets all addresses
           * - var select = new AddressSelect(id: new Guid("11111111-1111-1111-1111-111111111111"))  // Get a single address by id
           * - var select = new AddressSelect(isDeleted: true)  // Only gets the deleted addresses
           * - var select = new AddressSelect(new PagingSettings { PageNumber = 3, PageSize = 20 })
           * So a Select with WYSE can be used to encapsulate SQL logic,
           * making it kind of like a coded version of a SqlServer function or view,
           * but much more flexible!
           */
          protected ItemSubselectBase(
              ItemTableBase<TItem> sourceTable,
              TraceTree parentTraceTree,
              PagingSettings? pagingSettings,  /* If not null then paging is added to the query */
              Guid? id,  /* If not null then a select by id is done */
              bool? isDeleted)  /* If 'null' then both deleted and not deleted */
          {
              var traceTree = parentTraceTree?.AddChild();
              traceTree?.RecordCodeConstructorExecution(typeof(ItemSubselectBase<TSelect, TItem>));
          
              _sourceListConvert = sourceTable.Convert;
          
              // Funneling is a concept used in WYSE to expose the columns of a (nested)
              // subselect one level higher in a query, so it can be used in a From or in
              // Where/Join expressions for example.
              Id = /*WYSE*/Funnel(sourceTable.Id);
              Created = /*WYSE*/Funnel(sourceTable.Created);
              LastModified = /*WYSE*/Funnel(sourceTable.LastModified);
              IsDeleted = /*WYSE*/Funnel(sourceTable.IsDeleted);
          
              var columnExpressions = new List</*WYSE*/IExpression>(
                  sourceTable./*WYSE*/ListColumns());
          
              if (pagingSettings is not null)
              {
                  // Add SqlServer's 'COUNT(Id) OVER()' to selected columns.
                  // The modifying of the Where clause for row selection is done in
                  // the query backbone. Check the traces below.
                  sourceTable.CountUnpaged = new /*WYSE*/Count(sourceTable.Id).Over();
                  CountUnpaged = /*WYSE*/Funnel(sourceTable.CountUnpaged);
          
                  columnExpressions.Add(sourceTable.CountUnpaged);
              }
          
              // This makes the statement: SELECT [columnExpressions] FROM [sourceList]
              /*WYSE*/From from = this./*WYSE*/Columns(columnExpressions).From(sourceTable);
          
              // Determine the applicable where clause sub expressions (based on SQL parameters)
              var whereExpressions = new List</*WYSE*/BooleanExpression>();
          
              if (id.HasValue)
              {
                  whereExpressions.Add(
                      sourceTable.Id == new /*WYSE*/UniqueIdentifierParam("Id", id));
              }
              if (isDeleted.HasValue)
              {
                  whereExpressions.Add(
                      sourceTable.IsDeleted == new /*WYSE*/BitParam("IsDeleted", isDeleted));
              }
          
              if (whereExpressions.Count > 0)
              {
                  // Append a Where clause with a condition that is all the
                  // sub expressions 'AND'-ed together
                  from.Where(whereExpressions./*WYSE*/And());
              }
          }
      • Trace Entries: 4
          ...Framework.Services.ServiceBase.GetItem:
          protected async Task<TItem> GetItem<TItem>(
              Select select,
              Converter<DbDataReader, TItem> converter,
              TraceTree parentTraceTree)
              where TItem : ItemBase
          {
              var traceTree = parentTraceTree.AddChild();
              traceTree.RecordCodeMethodExecution(MethodBase.GetCurrentMethod());
          
              // A scriptable can be anything in the WYSE language that can be part of a script:
              // - Executables; like Selects, Inserts, Updates, Deletes, Merges (SqlServer only)
              // - Variable and Temp table declarations
              // - If/Elses
              // ...and more.
              var scriptables = new List</*WYSE*/IScriptable>();
          
              _queryBackbone.Using(traceTree).Modify(select, scriptables);
          
              return await _sqlExecuter.GetScriptItemAsync(
                  // Create new script combining scriptables with select
                  new /*WYSE*/Script(scriptables) + select,
                  converter,
                  parentTraceTree);
          }
        • Trace Entries: 1
            ...Framework.DataSpace.Queries.Modification.QueryBackbone.Modify:
            public override void Modify(
                /*WYSE*/Select select,
                List</*WYSE*/IScriptable> preparationScriptables)
            {
                var traceTree = _parentTraceTree.AddChild();
                traceTree.RecordCodeMethodExecution(MethodBase.GetCurrentMethod());
            
                // You can build a pipleline of modifiers to modify an executable (here a Select),
                // and add scriptables (like table variables) used in the modified Select.
                // These modifiers let you cut/paste strongly typed SQL language snippets.
                // In the case of this Framework Demo there are 3 custom modifiers:
                // - Division security decorator
                // - Paging
                // - Identifiers resetter
                // ...more on those below.
                base.Modify(select, preparationScriptables);
            }
        • Trace Entries: 4
            ...Framework.DataSpace.Queries.Modification.DivisionSecurityDecorator.Modify:
            public void Modify(/*WYSE*/Select select, List</*WYSE*/IScriptable> scriptables)
            {
                var traceTree = _parentTraceTree.AddChild();
                traceTree.RecordCodeMethodExecution(MethodBase.GetCurrentMethod());
            
                if (!select.Uses<IDivisionReferringTable>())
                {
                    return;
                }
            
                // Put all the Ids of the divisions the current user has rights to in a 
                // TableVariable (Inherits from WYSE SqlServer TableVariable).
                var userDivisionIdsTableVariable = new UserDivisionIdsTableVariable();
            
                scriptables.Add(new /*WYSE*/Declare(userDivisionIdsTableVariable));
            
                var fillTableVariable = new UserDivisionIdsTableVariable.Fill(
                    userDivisionIdsTableVariable,
                    _sessionContext.CurrentUser.DivisionId,
                    traceTree);
            
                scriptables.Add(fillTableVariable);
            
                // This is a WYSE ISnippetReplacementFactory
                var securityReplacement = new SecurityReplacement(
                    userDivisionIdsTableVariable,
                    traceTree);
            
                // SQL Statements can be remade by chaining multiple ISnippetReplacementFactory instances.
                // Here just one is needed.
                _ = /*WYSE*/StatementRebuilder.Rebuild(
                    select,
                    /* rebuild the original Select, instead of a clone of it that is returned */
                    rebuildOnClone: false,
                    [securityReplacement]);
            }
          • Trace Entries: 2
              ...Framework.DataSpace.Queries.Systems.UserDivisionIdsTableVariable+Fill ctor:
              // The Fill class inherits from WYSE InsertInto
              public Fill(
                  UserDivisionIdsTableVariable tableVariable,
                  Guid userDivisionId,
                  TraceTree parentTraceTree)
                  : base(tableVariable)
              {
                  var traceTree = parentTraceTree.AddChild();
                  traceTree.RecordCodeConstructorExecution(typeof(Fill));
              
                  var getDescendents = new GetDescendentsTableFunction(userDivisionId, traceTree);
              
                  Select getDescendentsSelect = new /*WYSE*/Select()
                      .Columns(getDescendents.DivisionId)
                      .From(getDescendents);
              
                  // Insert into tableVariable the Select result of the table function.
                  this./*WYSE*/Columns(tableVariable)
                      .Select(getDescendentsSelect);
              }
            • Trace Entries: 1
                ...Framework.DataSpace.Entities.Relational.Systems.GetDescendantsTableFunction ctor:
                // Returns a table with a division id and the ids of all its descendents.
                public GetDescendantsTableFunction(
                    Guid divisionId,
                    TraceTree parentTraceTree)
                    : base()
                {
                    var traceTree = parentTraceTree.AddChild();
                    traceTree.RecordCodeConstructorExecution(GetType());
                
                    // When just using/calling the function setting the parameter value is enough.
                    DivisionIdParam.SetValue(divisionId);
                
                    var parentTable = new DivisionHierarchyTable().WithAlias("parent");
                    var childTable = new DivisionHierarchyTable().WithAlias("child");
                    var inTable = new DivisionHierarchyTable().WithAlias("i");
                
                    // This Select is NOT necessary when merely calling the function.
                    // (only needed when WYSE deploys the database).
                    // The Select is added here just to show what is under the GetDescendents-hood.
                    Select = new Select()
                        .Distinct()
                        .Columns(childTable.DivisionId.WithAlias("DivisionId"))
                        .From(parentTable)
                        // DivisionNodeId is of SqlServer type 'HierarchyId'
                        // IsDescendantOf is a built-in SqlServer function that WYSE supports
                        .InnerJoin(
                            childTable,
                            childTable.DivisionNodeId
                                .IsDescendantOf(parentTable.DivisionNodeId) == true)
                        .Where(parentTable.DivisionId.In(
                            new Select()
                                .Columns(inTable.DivisionId.WithAlias("DivisionId"))
                                .From(inTable)
                                .Where(inTable.DivisionId == DivisionIdParam)));
                }
          • Trace Entries: 1
              ...Framework.DataSpace.Queries.Modification.DivisionSecurityDecorator+SecurityReplacement.MustReplace:
              // In WYSE you can control whether or not replacement is necessary
              // for a SQL statement snippet.
              public bool MustReplace(Snippet snippet)
              {
                  if (!_mustReplaceTraceHasBeenRecorded)
                  {
                      var traceTree = _parentTraceTree.AddChild();
                      traceTree.RecordCodeMethodExecution(MethodBase.GetCurrentMethod());
                      _mustReplaceTraceHasBeenRecorded = true;
                  }
              
                  return
                      snippet is /*WYSE*/From from &&
                          from.List is IDivisionReferringTable
                      ||
                      snippet is /*WYSE*/Join join &&
                          join.TargetList is IDivisionReferringTable;
              }
          • Trace Entries: 2
              ...Framework.DataSpace.Queries.Modification.DivisionSecurityDecorator+SecurityReplacement.GetReplacements:
              // In WYSE replacing can be used to remove, change, or add as you see fit.
              public IReadOnlyList</*WYSE*/Snippet> GetReplacements(
                  /*WYSE*/Snippet snippet)
              {
                  var traceTree = _parentTraceTree.AddChild();
                  traceTree.RecordCodeMethodExecution(MethodBase.GetCurrentMethod());
              
                  // In this case we always want to keep the original SQL snippet.
                  var replacements = new List</*WYSE*/Snippet> { snippet };
              
                  if (snippet is /*WYSE*/From from &&
                      from.List is IDivisionReferringTable fromTable)
                  {
                      replacements.Add(CreateDivisionSecurityJoin(fromTable, traceTree));
                  }
                  else if (snippet is /*WYSE*/Join join &&
                      join.TargetList is IDivisionReferringTable joinTable)
                  {
                      replacements.Add(CreateDivisionSecurityJoin(joinTable, traceTree));
                  }
              
                  return replacements;
              }
            • Trace Entries: 1
                ...Framework.DataSpace.Queries.Modification.DivisionSecurityDecorator+SecurityReplacement.CreateDivisionSecurityJoin:
                private InnerJoin CreateDivisionSecurityJoin(
                    IDivisionReferringTable referringTable,
                    TraceTree parentTraceTree)
                {
                    var traceTree = parentTraceTree.AddChild();
                    traceTree.RecordCodeMethodExecution(MethodBase.GetCurrentMethod());
                
                    Select divisionsSelect = new /*WYSE*/Select()
                        .Columns(_userDivisionIdsTableVariable.DivisionId)
                        .From(_userDivisionIdsTableVariable);
                    // Alternatively...
                    // var divisionsSelect = /*WYSE*/SelectBuilder.Build(_userDivisionIdsTableVariable);
                
                    // Join with the funneled division id of the table variable used
                    // in the division select.
                    var joinExpression = referringTable.DivisionId ==
                        divisionsSelect[_userDivisionIdsTableVariable.DivisionId];
                
                    return new /*WYSE*/InnerJoin(divisionsSelect, joinExpression);
                }
        • Trace Entries: 1
            ...Framework.DataSpace.Queries.Modification.PagingDecorator.Modify:
            public void Modify(/*WYSE*/Select select, List</*WYSE*/IScriptable> preparationScriptables)
            {
                var traceTree = _parentTraceTree.AddChild();
                traceTree.RecordCodeMethodExecution(MethodBase.GetCurrentMethod());
                
                if (_pagingSettings is null)
                {
                    return;
                }
            
                // SQL Statements can be remade by chaining multiple ISnippetReplacementFactory instances.
                // Here just one is needed.
                _ = /*WYSE*/StatementRebuilder.Rebuild(
                    select,
                    /* rebuild the original Select, instead of a clone of it that is returned */
                    rebuildOnClone: false,
                    [new PagingAppending(select, _pagingSettings, traceTree)]);
            }
      • Trace Entries: 1
          ...Framework.DataSpace.Access.SqlExecuter.GetScriptItemAsync:
          public async Task<TItem> GetScriptItemAsync<TItem>(
              /*WYSE*/IScript script,
              Converter<DbDataReader, TItem> converter,
              TraceTree parentTraceTree)
          {
              var traceTree = parentTraceTree.AddChild();
              traceTree.RecordCodeMethodExecution(MethodBase.GetCurrentMethod());
          
              return await Get(
                  script,
                  reader => reader./*WYSE*/GetItem(converter),
                  parentTraceTree);
          }
      • Trace Entries: 2
          ...Framework.DataSpace.Access.SqlExecuter.Get:
          private async Task<TItem> Get<TItem>(
              /*WYSE*/IExecutable executable,  /* A Select or a Script */
              Func<DbDataReader, TItem> getResult,
              TraceTree parentTraceTree)
          {
              var traceTree = parentTraceTree.AddChild();
              traceTree.RecordCodeMethodExecution(MethodBase.GetCurrentMethod());
          
              using SqlConnection connection = _connectionFactory.Create();
              connection.Open();
          
              // 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);
          
              try
              {
                  using var reader = await command.ExecuteReaderAsync();
          
                  var result = getResult(reader);
          
                  traceTree.RecordDbCommandExecutionSuccess(
                      command.CommandText,
                      command.Parameters.ToDictionary(),
                      result);
          
                  return result;
              }
              catch (Exception exception)
              {
                  traceTree.RecordDbCommandExecutionFailure(
                      command.CommandText,
                      command.Parameters.ToDictionary(),
                      exception);
          
                  return default;
              }
          }

          Command Parameters:

          @Id : 11111111-1111-1111-1111-111111111111
          @IsDeleted : False

          Command Text:

          DECLARE @UserDivisionIds AS TABLE (
              [DivisionId] uniqueidentifier NOT NULL
          );
          
          INSERT INTO @UserDivisionIds
          ([DivisionId])
          SELECT [56154_FrameworkDemoSystems_dbo_GetDescendants].[DivisionId] [DivisionId_1]
          FROM [56154_FrameworkDemoSystems].[dbo].[GetDescendants]('11111111-1111-1111-1111-111111111111') [56154_FrameworkDemoSystems_dbo_GetDescendants];
          
          SELECT
              [_CustomerSubselect].[56154_FrameworkDemoCustomers_demo_Customer_FullName] [_StringFunnel],
              [_CustomerSubselect].[56154_FrameworkDemoCustomers_demo_Customer_DivisionId] [_GuidFunnel_1],
              [_CustomerSubselect].[56154_FrameworkDemoCustomers_demo_Customer_HomeAddressId] [_GuidFunnel_2],
              [_CustomerSubselect].[56154_FrameworkDemoCustomers_demo_Customer_BillingAddressId] [_NullableGuidFunnel_1],
              [_CustomerSubselect].[56154_FrameworkDemoCustomers_demo_Customer_Id] [_GuidFunnel_3],
              [_CustomerSubselect].[56154_FrameworkDemoCustomers_demo_Customer_Created] [_DateTimeFunnel_1],
              [_CustomerSubselect].[56154_FrameworkDemoCustomers_demo_Customer_LastModified] [_DateTimeFunnel_2],
              [_CustomerSubselect].[56154_FrameworkDemoCustomers_demo_Customer_IsDeleted] [_BooleanFunnel]
          FROM
          (
              SELECT
                  [56154_FrameworkDemoCustomers_demo_Customer].[FullName] [56154_FrameworkDemoCustomers_demo_Customer_FullName],
                  [56154_FrameworkDemoCustomers_demo_Customer].[DivisionId] [56154_FrameworkDemoCustomers_demo_Customer_DivisionId],
                  [56154_FrameworkDemoCustomers_demo_Customer].[HomeAddressId] [56154_FrameworkDemoCustomers_demo_Customer_HomeAddressId],
                  [56154_FrameworkDemoCustomers_demo_Customer].[BillingAddressId] [56154_FrameworkDemoCustomers_demo_Customer_BillingAddressId],
                  [56154_FrameworkDemoCustomers_demo_Customer].[Id] [56154_FrameworkDemoCustomers_demo_Customer_Id],
                  [56154_FrameworkDemoCustomers_demo_Customer].[Created] [56154_FrameworkDemoCustomers_demo_Customer_Created],
                  [56154_FrameworkDemoCustomers_demo_Customer].[LastModified] [56154_FrameworkDemoCustomers_demo_Customer_LastModified],
                  [56154_FrameworkDemoCustomers_demo_Customer].[IsDeleted] [56154_FrameworkDemoCustomers_demo_Customer_IsDeleted]
              FROM [56154_FrameworkDemoCustomers].[demo].[Customer] [56154_FrameworkDemoCustomers_demo_Customer]
              INNER JOIN
              (
                  SELECT [UserDivisionIds].[DivisionId] [UserDivisionIds_DivisionId]
                  FROM @UserDivisionIds [UserDivisionIds]
              ) [_Select_2] ON ([56154_FrameworkDemoCustomers_demo_Customer].[DivisionId] = [_Select_2].[UserDivisionIds_DivisionId])
              WHERE
              (
                  ([56154_FrameworkDemoCustomers_demo_Customer].[Id] = @Id)
                  AND
                  ([56154_FrameworkDemoCustomers_demo_Customer].[IsDeleted] = @IsDeleted)
              )
          ) [_CustomerSubselect];

Command Parameters:

@Id : 11111111-1111-1111-1111-111111111111
@IsDeleted : False

Command Text:

DECLARE @UserDivisionIds AS TABLE (
    [DivisionId] uniqueidentifier NOT NULL
);

INSERT INTO @UserDivisionIds
([DivisionId])
SELECT [56154_FrameworkDemoSystems_dbo_GetDescendants].[DivisionId] [DivisionId_1]
FROM [56154_FrameworkDemoSystems].[dbo].[GetDescendants]('11111111-1111-1111-1111-111111111111') [56154_FrameworkDemoSystems_dbo_GetDescendants];

SELECT
    [_CustomerSubselect].[56154_FrameworkDemoCustomers_demo_Customer_FullName] [_StringFunnel],
    [_CustomerSubselect].[56154_FrameworkDemoCustomers_demo_Customer_DivisionId] [_GuidFunnel_1],
    [_CustomerSubselect].[56154_FrameworkDemoCustomers_demo_Customer_HomeAddressId] [_GuidFunnel_2],
    [_CustomerSubselect].[56154_FrameworkDemoCustomers_demo_Customer_BillingAddressId] [_NullableGuidFunnel_1],
    [_CustomerSubselect].[56154_FrameworkDemoCustomers_demo_Customer_Id] [_GuidFunnel_3],
    [_CustomerSubselect].[56154_FrameworkDemoCustomers_demo_Customer_Created] [_DateTimeFunnel_1],
    [_CustomerSubselect].[56154_FrameworkDemoCustomers_demo_Customer_LastModified] [_DateTimeFunnel_2],
    [_CustomerSubselect].[56154_FrameworkDemoCustomers_demo_Customer_IsDeleted] [_BooleanFunnel]
FROM
(
    SELECT
        [56154_FrameworkDemoCustomers_demo_Customer].[FullName] [56154_FrameworkDemoCustomers_demo_Customer_FullName],
        [56154_FrameworkDemoCustomers_demo_Customer].[DivisionId] [56154_FrameworkDemoCustomers_demo_Customer_DivisionId],
        [56154_FrameworkDemoCustomers_demo_Customer].[HomeAddressId] [56154_FrameworkDemoCustomers_demo_Customer_HomeAddressId],
        [56154_FrameworkDemoCustomers_demo_Customer].[BillingAddressId] [56154_FrameworkDemoCustomers_demo_Customer_BillingAddressId],
        [56154_FrameworkDemoCustomers_demo_Customer].[Id] [56154_FrameworkDemoCustomers_demo_Customer_Id],
        [56154_FrameworkDemoCustomers_demo_Customer].[Created] [56154_FrameworkDemoCustomers_demo_Customer_Created],
        [56154_FrameworkDemoCustomers_demo_Customer].[LastModified] [56154_FrameworkDemoCustomers_demo_Customer_LastModified],
        [56154_FrameworkDemoCustomers_demo_Customer].[IsDeleted] [56154_FrameworkDemoCustomers_demo_Customer_IsDeleted]
    FROM [56154_FrameworkDemoCustomers].[demo].[Customer] [56154_FrameworkDemoCustomers_demo_Customer]
    INNER JOIN
    (
        SELECT [UserDivisionIds].[DivisionId] [UserDivisionIds_DivisionId]
        FROM @UserDivisionIds [UserDivisionIds]
    ) [_Select_2] ON ([56154_FrameworkDemoCustomers_demo_Customer].[DivisionId] = [_Select_2].[UserDivisionIds_DivisionId])
    WHERE
    (
        ([56154_FrameworkDemoCustomers_demo_Customer].[Id] = @Id)
        AND
        ([56154_FrameworkDemoCustomers_demo_Customer].[IsDeleted] = @IsDeleted)
    )
) [_CustomerSubselect];