### All Quantifier Queries Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore10.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md Examples of LINQ All operations translated to T-SQL using NOT EXISTS clauses. ```SQL SELECT CASE WHEN NOT EXISTS ( SELECT 1 FROM [EfParents] AS [e] WHERE [e].[ParentInt] <> 123) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END ``` ```SQL SELECT CASE WHEN NOT EXISTS ( SELECT 1 FROM [EfChildren] AS [e0] WHERE [e].[EfParentId] = [e0].[EfParentId] AND [e0].[ChildInt] <> 123) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [EfParents] AS [e] ``` -------------------------------- ### Any Quantifier Queries Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore10.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md Examples of LINQ Any operations translated to T-SQL using EXISTS clauses. ```SQL SELECT CASE WHEN EXISTS ( SELECT 1 FROM [EfChildren] AS [e0] WHERE [e].[EfParentId] = [e0].[EfParentId]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [EfParents] AS [e] ``` ```SQL SELECT CASE WHEN EXISTS ( SELECT 1 FROM [EfChildren] AS [e0] WHERE [e].[EfParentId] = [e0].[EfParentId] AND [e0].[ChildInt] = 123) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [EfParents] AS [e] ``` -------------------------------- ### Print Method Expression using Decompile Source: https://context7.com/hazzik/delegatedecompiler/llms.txt A practical example of using MethodInfo.Decompile() to inspect a method's body at runtime and print its expression tree representation, parameters, and body. Requires DelegateDecompiler. ```csharp using DelegateDecompiler; using System; using System.Reflection; using System.Linq.Expressions; public class Calculator { public int Square(int x) => x * x; public bool IsEven(int x) => x % 2 == 0; public string Format(int x) => "Value: " + x.ToString(); } // Practical use: Inspect method body at runtime public static void PrintMethodExpression(MethodInfo method) { var expression = method.Decompile(); Console.WriteLine($"Method: {method.Name}"); Console.WriteLine($"Expression: {expression}"); Console.WriteLine($"Parameters: {string.Join(", ", expression.Parameters)}"); Console.WriteLine($"Body: {expression.Body}"); } ``` -------------------------------- ### Skip and Take Queries Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore10.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md Examples of LINQ Skip and Take operations translated to T-SQL, including combinations with sorting and filtering. ```SQL SELECT TOP(@p) [e].[EfParentId] FROM [EfParents] AS [e] ORDER BY ( SELECT COUNT(*) FROM [EfChildren] AS [e0] WHERE [e].[EfParentId] = [e0].[EfParentId]) ``` ```SQL SELECT [e].[EfParentId] FROM [EfParents] AS [e] ORDER BY ( SELECT COUNT(*) FROM [EfChildren] AS [e0] WHERE [e].[EfParentId] = [e0].[EfParentId]) OFFSET @p ROWS FETCH NEXT @p0 ROWS ONLY ``` ```SQL SELECT [e].[EfParentId] FROM [EfParents] AS [e] WHERE EXISTS ( SELECT 1 FROM [EfChildren] AS [e0] WHERE [e].[EfParentId] = [e0].[EfParentId]) ORDER BY ( SELECT COUNT(*) FROM [EfChildren] AS [e1] WHERE [e].[EfParentId] = [e1].[EfParentId]) OFFSET @p ROWS FETCH NEXT @p ROWS ONLY ``` -------------------------------- ### Order By Queries Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore10.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md Examples of LINQ OrderBy operations translated to T-SQL, including sorting by subquery counts and string lengths. ```SQL SELECT [e].[EfParentId] FROM [EfParents] AS [e] ORDER BY ( SELECT COUNT(*) FROM [EfChildren] AS [e0] WHERE [e].[EfParentId] = [e0].[EfParentId]) ``` ```SQL SELECT [e].[EfParentId] FROM [EfParents] AS [e] ORDER BY ( SELECT COUNT(*) FROM [EfChildren] AS [e0] WHERE [e].[EfParentId] = [e0].[EfParentId]), CAST(LEN([e].[ParentString]) AS int) ``` ```SQL SELECT [e].[EfParentId] FROM [EfParents] AS [e] WHERE EXISTS ( SELECT 1 FROM [EfChildren] AS [e0] WHERE [e].[EfParentId] = [e0].[EfParentId]) ORDER BY ( SELECT COUNT(*) FROM [EfChildren] AS [e1] WHERE [e].[EfParentId] = [e1].[EfParentId]) ``` -------------------------------- ### DateTime Where Compare With Static Variable (T-SQL) Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFramework.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md Generates T-SQL for comparing a start date with a static variable, used for filtering records based on a date range. ```SQL SELECT [Extent1].[StartDate] AS [StartDate] FROM [dbo].[EfParents] AS [Extent1] WHERE [Extent1].[StartDate] > @p__linq__0 ``` -------------------------------- ### Contains Operator Query Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore10.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md Example of LINQ Contains operation translated to T-SQL using the LIKE operator. ```SQL SELECT [e].[ParentString] FROM [EfParents] AS [e] WHERE [e].[ParentString] LIKE N'%2%' ``` -------------------------------- ### IQueryable.Decompile() Usage Source: https://context7.com/hazzik/delegatedecompiler/llms.txt Demonstrates how to use the Decompile() extension method with various LINQ operations like ToList(), Select(), Count(), FirstOrDefault(), Any(), OrderBy(), and Take(). ```APIDOC ## IQueryable.Decompile() ### Description The `Decompile()` extension method wraps an `IQueryable` to automatically decompile computed properties when the query is executed. It should be called just before materialization methods like `ToList()`, `FirstOrDefault()`, etc. ### Method Extension Method (applied to IQueryable) ### Endpoint N/A (In-memory LINQ extension) ### Parameters None ### Request Example ```csharp // Basic usage - call Decompile() before ToList() var orders = db.Orders .Where(o => o.Total > 500) .Decompile() .ToList(); // Works with Select projections var orderSummaries = db.Orders .Select(o => new { o.OrderId, o.Total, o.TaxAmount, o.IsLargeOrder }) .Decompile() .ToList(); // Works with aggregation methods var largeOrderCount = db.Orders .Decompile() .Count(o => o.IsLargeOrder); // Works with First, Single, Any, etc. var firstBigOrder = db.Orders .Where(o => o.Total > 1000) .Decompile() .FirstOrDefault(); bool hasExpensiveOrders = db.Orders .Decompile() .Any(o => o.Total > 5000); // Works with OrderBy var sortedOrders = db.Orders .OrderByDescending(o => o.Total) .Decompile() .Take(10) .ToList(); ``` ### Response #### Success Response (200) Returns the materialized result of the LINQ query after decompiling computed properties. #### Response Example (Depends on the specific query and data) ```json // Example for ToList() [ { "OrderId": 1, "Total": 550.75, "TaxAmount": 50.75, "IsLargeOrder": false } ] // Example for FirstOrDefault() { "OrderId": 2, "Total": 1200.50, "TaxAmount": 100.50, "IsLargeOrder": true } ``` ``` -------------------------------- ### Configuration.Configure() Source: https://context7.com/hazzik/delegatedecompiler/llms.txt Sets up a custom configuration class to determine which members should be decompiled based on custom logic or naming conventions. ```APIDOC ## Configuration.Configure(Configuration config) ### Description Registers a custom configuration instance to define which members are eligible for decompilation. This must be called once at application startup before any decompilation occurs. ### Parameters #### Request Body - **config** (Configuration) - Required - An instance of a class inheriting from `DelegateDecompiler.Configuration` that implements `ShouldDecompile(MemberInfo)` and `RegisterDecompileableMember(MemberInfo)`. ### Request Example ```csharp Configuration.Configure(new ConventionBasedConfiguration()); ``` ``` -------------------------------- ### Configure custom decompilation conventions Source: https://context7.com/hazzik/delegatedecompiler/llms.txt Implement a custom Configuration class to define member decompilation rules. This must be registered at application startup before any queries are executed. ```csharp using DelegateDecompiler; using System.Reflection; // Custom configuration that decompiles all properties ending with "Computed" public class ConventionBasedConfiguration : Configuration { private readonly HashSet _registeredMembers = new(); public override bool ShouldDecompile(MemberInfo memberInfo) { // Check if explicitly registered if (_registeredMembers.Contains(memberInfo)) return true; // Check for attributes if (memberInfo.GetCustomAttributes(typeof(ComputedAttribute), true).Length > 0) return true; if (memberInfo.GetCustomAttributes(typeof(DecompileAttribute), true).Length > 0) return true; // Convention: properties ending with "Computed" are decompiled if (memberInfo.Name.EndsWith("Computed")) return true; // Convention: methods starting with "Get" and ending with "Computed" are decompiled if (memberInfo is MethodInfo && memberInfo.Name.StartsWith("Get") && memberInfo.Name.EndsWith("Computed")) return true; return false; } public override void RegisterDecompileableMember(MemberInfo member) { _registeredMembers.Add(member); } } // Configure at application startup (must be called before any decompilation) public class Startup { public void ConfigureServices() { // Must be called only once, before any queries Configuration.Configure(new ConventionBasedConfiguration()); } } // Entity using convention-based naming public class Order { public int OrderId { get; set; } public decimal Subtotal { get; set; } public decimal TaxRate { get; set; } public decimal DiscountPercent { get; set; } // Will be decompiled due to naming convention (no attribute needed) public decimal TaxAmountComputed => Subtotal * TaxRate; public decimal DiscountComputed => Subtotal * DiscountPercent / 100; public decimal TotalComputed => Subtotal + TaxAmountComputed - DiscountComputed; // Convention method public bool GetIsDiscountedComputed() => DiscountPercent > 0; } // Queries work without explicit Decompile() if using auto-decompilation var discountedOrders = db.Orders .Where(o => o.GetIsDiscountedComputed()) .Select(o => new { o.OrderId, o.TotalComputed }) .Decompile() .ToList(); ``` -------------------------------- ### Nullable Init Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFramework.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md Initializes a nullable value as NULL. ```SQL SELECT CAST(NULL AS int) AS [C1] FROM [dbo].[EfParents] AS [Extent1] ``` -------------------------------- ### Register Computed Properties via Fluent API Source: https://context7.com/hazzik/delegatedecompiler/llms.txt Use the Computed() extension method on EntityTypeBuilder to register computed properties when not using attributes. This example shows configuration for Customer properties. ```csharp using DelegateDecompiler.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; public class Customer { public int CustomerId { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public decimal CreditLimit { get; set; } public decimal OutstandingBalance { get; set; } public List Orders { get; set; } // Properties without attributes - will be configured via Fluent API public string FullName => FirstName + " " + LastName; public decimal AvailableCredit => CreditLimit - OutstandingBalance; public bool HasOrders => Orders.Any(); public int OrderCount => Orders.Count(); } public class CustomerConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.HasKey(c => c.CustomerId); builder.Property(c => c.FirstName).HasMaxLength(100); builder.Property(c => c.LastName).HasMaxLength(100); // Register computed properties using Fluent API builder.Computed(c => c.FullName); builder.Computed(c => c.AvailableCredit); builder.Computed(c => c.HasOrders); builder.Computed(c => c.OrderCount); // Configure navigation builder.HasMany(c => c.Orders) .WithOne(o => o.Customer) .HasForeignKey(o => o.CustomerId); } } public class AppDbContext : DbContext { public DbSet Customers { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.ApplyConfiguration(new CustomerConfiguration()); } protected override void OnConfiguring(DbContextOptionsBuilder options) { options .UseSqlServer("your-connection-string") .AddDelegateDecompiler(); } } // Usage - computed properties work without [Computed] attribute var creditRisks = await db.Customers .Where(c => c.AvailableCredit < 100 && c.HasOrders) .Select(c => new { c.FullName, c.AvailableCredit, c.OrderCount }) .ToListAsync(); ``` -------------------------------- ### Nullable Init Query Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore8.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md SQL generated for a nullable initialization, resulting in a NULL value. ```SQL SELECT NULL FROM [EfParents] AS [e] ``` -------------------------------- ### Skip and Take Operations Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore8.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md T-SQL generated for pagination and ordering combinations. ```SQL SELECT TOP(@__p_0) [e].[EfParentId] FROM [EfParents] AS [e] ORDER BY ( SELECT COUNT(*) FROM [EfChildren] AS [e0] WHERE [e].[EfParentId] = [e0].[EfParentId]) ``` ```SQL SELECT [e].[EfParentId] FROM [EfParents] AS [e] ORDER BY ( SELECT COUNT(*) FROM [EfChildren] AS [e0] WHERE [e].[EfParentId] = [e0].[EfParentId]) OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY ``` ```SQL SELECT [e].[EfParentId] FROM [EfParents] AS [e] WHERE EXISTS ( SELECT 1 FROM [EfChildren] AS [e0] WHERE [e].[EfParentId] = [e0].[EfParentId]) ORDER BY ( SELECT COUNT(*) FROM [EfChildren] AS [e1] WHERE [e].[EfParentId] = [e1].[EfParentId]) OFFSET @__p_0 ROWS FETCH NEXT @__p_0 ROWS ONLY ``` -------------------------------- ### Select Async Query Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore8.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md SQL generated for a basic asynchronous select operation. ```SQL SELECT [e].[EfParentId], [e].[EndDate], [e].[ParentBool], [e].[ParentDouble], [e].[ParentInt], [e].[ParentNullableDecimal1], [e].[ParentNullableDecimal2], [e].[ParentNullableInt], [e].[ParentString], [e].[ParentTimeSpan], [e].[StartDate] FROM [EfParents] AS [e] ``` -------------------------------- ### Select Abstract Member Over TPH Hierarchy With Generic Classes Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore8.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md Demonstrates mapping multiple abstract members for generic classes after restricting to specific subtypes. ```SQL SELECT CASE WHEN [l].[Discriminator] = N'WhiteShark' THEN N'Carcharodon carcharias' WHEN [l].[Discriminator] = N'AtlanticCod' THEN N'Gadus morhua' ELSE NULL END AS [Species], CASE WHEN [l].[Discriminator] = N'WhiteShark' THEN N'Fish' WHEN [l].[Discriminator] = N'AtlanticCod' THEN N'Fish' ELSE NULL END AS [Group] FROM [LivingBeeing] AS [l] WHERE [l].[Discriminator] IN (N'AtlanticCod', N'WhiteShark') ``` -------------------------------- ### Configure automatic decompilation for EF Core Source: https://github.com/hazzik/delegatedecompiler/blob/main/README.md Use options.AddDelegateDecompiler() in the DbContext configuration to enable automatic decompilation for all queries. ```csharp public class YourDbContext : DbContext { protected override void OnConfiguring(DbContextOptionsBuilder options) { options.AddDelegateDecompiler(); // Other configuration } } ``` -------------------------------- ### Decompile MethodInfo with Declaring Type Source: https://context7.com/hazzik/delegatedecompiler/llms.txt Shows how to decompile a MethodInfo while specifying the declaring type, which is useful in inheritance scenarios. Requires DelegateDecompiler. ```csharp using DelegateDecompiler; using System.Reflection; using System.Linq.Expressions; public class Calculator { public int Square(int x) => x * x; public bool IsEven(int x) => x % 2 == 0; public string Format(int x) => "Value: " + x.ToString(); } // Decompile with specific declaring type (for inheritance scenarios) var formatMethod = typeof(Calculator).GetMethod("Format"); LambdaExpression formatExpr = formatMethod.Decompile(typeof(Calculator)); ``` -------------------------------- ### Select Multiple Levels Of Abstract Members Over TPH Hierarchy Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore8.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md Demonstrates nested mapping of abstract members across a TPH hierarchy. ```SQL SELECT CASE WHEN [l].[Discriminator] = N'HoneyBee' THEN N'Apis mellifera' WHEN [l].[Discriminator] = N'Dog' THEN N'Canis lupus' ELSE NULL END, CASE WHEN [l].[Discriminator] = N'HoneyBee' THEN CAST(0 AS bit) ELSE CASE WHEN [l].[Discriminator] = N'Dog' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END END FROM [LivingBeeing] AS [l] WHERE [l].[Discriminator] IN (N'Dog', N'HoneyBee') ``` -------------------------------- ### Configure DbContext for Automatic Decompilation Source: https://context7.com/hazzik/delegatedecompiler/llms.txt Use the AddDelegateDecompiler() extension method in OnConfiguring to enable automatic query decompilation for all queries in your DbContext. ```csharp using DelegateDecompiler.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; // Configure DbContext for automatic decompilation public class AppDbContext : DbContext { public DbSet Employees { get; set; } public DbSet Departments { get; set; } public DbSet Projects { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder options) { options .UseSqlServer("your-connection-string") .AddDelegateDecompiler(); // Enable automatic decompilation } } public class Employee { public int EmployeeId { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public decimal Salary { get; set; } public int DepartmentId { get; set; } public Department Department { get; set; } public List Projects { get; set; } [Computed] public string FullName => FirstName + " " + LastName; [Computed] public int ProjectCount => Projects.Count(); [Computed] public bool IsHighPerformer => ProjectCount > 5; } public class EmployeeService { private readonly AppDbContext _db; // No need to call Decompile() - it happens automatically public async Task> GetHighPerformersAsync() { return await _db.Employees .Where(e => e.IsHighPerformer) .ToListAsync(); } public async Task> GetEmployeeNamesAsync() { return await _db.Employees .Select(e => e.FullName) .ToListAsync(); } public async Task FindByNameAsync(string fullName) { return await _db.Employees .FirstOrDefaultAsync(e => e.FullName == fullName); } public async Task CountActiveEmployeesAsync() { return await _db.Employees .CountAsync(e => e.ProjectCount > 0); } } ``` -------------------------------- ### Select Select Many Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore8.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md Demonstrates a SelectMany operation involving joins and row numbering for pagination or limiting. ```SQL SELECT [t0].[EfGrandChildId], [t0].[EfChildId], [t0].[GrandChildBool], [t0].[GrandChildDouble], [t0].[GrandChildInt], [t0].[GrandChildString] FROM [EfParents] AS [e] LEFT JOIN ( SELECT [t].[EfGrandChildId], [t].[EfChildId], [t].[GrandChildBool], [t].[GrandChildDouble], [t].[GrandChildInt], [t].[GrandChildString], [t].[EfParentId] FROM ( SELECT [e1].[EfGrandChildId], [e1].[EfChildId], [e1].[GrandChildBool], [e1].[GrandChildDouble], [e1].[GrandChildInt], [e1].[GrandChildString], [e0].[EfParentId], ROW_NUMBER() OVER(PARTITION BY [e0].[EfParentId] ORDER BY [e1].[EfGrandChildId]) AS [row] FROM [EfChildren] AS [e0] INNER JOIN [EfGrandChildren] AS [e1] ON [e0].[EfChildId] = [e1].[EfChildId] ) AS [t] WHERE [t].[row] <= 1 ) AS [t0] ON [e].[EfParentId] = [t0].[EfParentId] ``` -------------------------------- ### Select Int Equals Constant Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore8.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md Demonstrates a select operation comparing an integer column to a constant value. ```SQL SELECT CASE WHEN [e].[ParentInt] = 123 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [EfParents] AS [e] ``` -------------------------------- ### Int Equals Static Variable Query Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore8.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md SQL generated for an integer equality check against a static variable. ```SQL SELECT CASE WHEN [e].[ParentInt] = @__staticInt_0 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [EfParents] AS [e] ``` -------------------------------- ### Order By Children Count Then Skip And Take Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFramework.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md This T-SQL query skips one record and takes the next two, ordered by children count. It uses EfParents and EfChilds tables. ```SQL SELECT [Project1].[EfParentId] AS [EfParentId] FROM ( SELECT [Extent1].[EfParentId] AS [EfParentId], (SELECT COUNT(1) AS [A1] FROM [dbo].[EfChilds] AS [Extent2] WHERE [Extent1].[EfParentId] = [Extent2].[EfParentId]) AS [C1] FROM [dbo].[EfParents] AS [Extent1] ) AS [Project1] ORDER BY row_number() OVER (ORDER BY [Project1].[C1] ASC) OFFSET 1 ROWS FETCH NEXT 2 ROWS ONLY ``` -------------------------------- ### Select Bool Equals Static Variable Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore8.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md Demonstrates a select operation comparing a column to a static variable using a CASE statement. ```SQL SELECT CASE WHEN [e].[ParentBool] = @__staticBool_0 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [EfParents] AS [e] ``` -------------------------------- ### Int Not Equals String Length Query Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore8.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md SQL generated for an integer inequality check against the length of a string. ```SQL SELECT CASE WHEN [e].[ParentInt] <> CAST(LEN([e].[ParentString]) AS int) OR [e].[ParentString] IS NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [EfParents] AS [e] ``` -------------------------------- ### Decompile Simple Delegate Source: https://context7.com/hazzik/delegatedecompiler/llms.txt Converts a simple Func delegate to a LambdaExpression. Ensure DelegateDecompiler is included. ```csharp using DelegateDecompiler; using System; using System.Linq.Expressions; // Decompile a simple delegate Func add = (x, y) => x + y; LambdaExpression addExpression = add.Decompile(); // Result: (x, y) => x + y ``` -------------------------------- ### Int Equals String Length Query Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore8.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md SQL generated for an integer equality check against the length of a string. ```SQL SELECT CASE WHEN [e].[ParentInt] = CAST(LEN([e].[ParentString]) AS int) AND [e].[ParentString] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [EfParents] AS [e] ``` -------------------------------- ### Decompile MethodInfo for IsEven Source: https://context7.com/hazzik/delegatedecompiler/llms.txt Demonstrates decompiling a method that returns a boolean. The resulting LambdaExpression can be inspected or used in expression trees. Ensure DelegateDecompiler is referenced. ```csharp using DelegateDecompiler; using System.Reflection; using System.Linq.Expressions; public class Calculator { public int Square(int x) => x * x; public bool IsEven(int x) => x % 2 == 0; public string Format(int x) => "Value: " + x.ToString(); } // Get MethodInfo and decompile var isEvenMethod = typeof(Calculator).GetMethod("IsEven"); LambdaExpression isEvenExpr = isEvenMethod.Decompile(); // Result: (Calculator this, int x) => x % 2 == 0 ``` -------------------------------- ### FilterBuilder for Dynamic Queryable Filters Source: https://context7.com/hazzik/delegatedecompiler/llms.txt A generic class that uses Delegate.Decompile() to convert delegates into LambdaExpressions, enabling dynamic filtering of IQueryable collections. Requires DelegateDecompiler. ```csharp using DelegateDecompiler; using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; // Practical example: Building queryable filters dynamically public class FilterBuilder { private readonly List>> _filters = new(); public void AddFilter(Func filter) { // Decompile delegate to expression for use with IQueryable var expression = filter.Decompile(); _filters.Add((Expression>)expression); } public IQueryable ApplyFilters(IQueryable query) { foreach (var filter in _filters) { query = query.Where(filter); } return query; } } // Usage // var builder = new FilterBuilder(); // builder.AddFilter(c => c.FirstName.StartsWith("J")); // builder.AddFilter(c => c.LastName != null); // var filtered = builder.ApplyFilters(db.Customers); ``` -------------------------------- ### Filter Generic Method Person Handle (T-SQL) Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFramework.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md Generates T-SQL for filtering persons based on their full name, ensuring the name is not null and handling potential nulls in the name components. ```SQL SELECT [Extent1].[EfPersonId] AS [EfPersonId], [Extent1].[FirstName] AS [FirstName], [Extent1].[MiddleName] AS [MiddleName], [Extent1].[LastName] AS [LastName], [Extent1].[NameOrder] AS [NameOrder] FROM [dbo].[EfPersons] AS [Extent1] WHERE [Extent1].[FirstName] + CASE WHEN (CASE WHEN ([Extent1].[MiddleName] IS NULL) THEN N'' ELSE N' ' END IS NULL) THEN N'' WHEN ([Extent1].[MiddleName] IS NULL) THEN N'' ELSE N' ' END + CASE WHEN ([Extent1].[MiddleName] IS NULL) THEN N'' ELSE [Extent1].[MiddleName] END + N' ' + [Extent1].[LastName] IS NOT NULL ``` -------------------------------- ### Order By Children Count Then Take Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFramework.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md This T-SQL query retrieves the top 2 parents ordered by their children count. It requires EfParents and EfChilds tables. ```SQL SELECT TOP (2) [Project1].[EfParentId] AS [EfParentId] FROM ( SELECT [Extent1].[EfParentId] AS [EfParentId], (SELECT COUNT(1) AS [A1] FROM [dbo].[EfChilds] AS [Extent2] WHERE [Extent1].[EfParentId] = [Extent2].[EfParentId]) AS [C1] FROM [dbo].[EfParents] AS [Extent1] ) AS [Project1] ORDER BY [Project1].[C1] ASC ``` -------------------------------- ### Select Abstract Member Over TPH Hierarchy Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore8.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md Demonstrates mapping abstract members to specific values based on the TPH discriminator column. ```SQL SELECT CASE WHEN [l].[Discriminator] = N'Person' THEN N'Human' WHEN [l].[Discriminator] = N'WhiteShark' THEN N'Carcharodon carcharias' WHEN [l].[Discriminator] = N'AtlanticCod' THEN N'Gadus morhua' WHEN [l].[Discriminator] = N'HoneyBee' THEN N'Apis mellifera' WHEN [l].[Discriminator] = N'Dog' THEN N'Canis lupus' ELSE NULL END FROM [LivingBeeing] AS [l] ``` -------------------------------- ### Equality and Inequality Operations Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore9.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md T-SQL generated for integer equality, inequality, and string length comparisons. ```SQL SELECT ~CAST([e].[ParentInt] ^ 123 AS bit) FROM [EfParents] AS [e] ``` ```SQL SELECT ~CAST([e].[ParentInt] ^ @__staticInt_0 AS bit) FROM [EfParents] AS [e] ``` ```SQL SELECT CASE WHEN [e].[ParentInt] = CAST(LEN([e].[ParentString]) AS int) AND [e].[ParentString] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [EfParents] AS [e] ``` ```SQL SELECT CASE WHEN [e].[ParentInt] <> CAST(LEN([e].[ParentString]) AS int) OR [e].[ParentString] IS NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [EfParents] AS [e] ``` -------------------------------- ### Select Abstract Member Over TPH Hierarchy After Restricting To Subtype Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore8.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md Demonstrates filtering by discriminator and mapping abstract members for specific subtypes. ```SQL SELECT CASE WHEN [l].[Discriminator] = N'HoneyBee' THEN N'Apis mellifera' WHEN [l].[Discriminator] = N'Dog' THEN N'Canis lupus' ELSE NULL END FROM [LivingBeeing] AS [l] WHERE [l].[Discriminator] IN (N'Dog', N'HoneyBee') ``` -------------------------------- ### Nullable Add Query Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore8.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md SQL generated for adding two nullable decimal properties. ```SQL SELECT [e].[ParentNullableDecimal1] + [e].[ParentNullableDecimal2] FROM [EfParents] AS [e] ``` -------------------------------- ### EF Core 5+ DecompileAsync() for Async Operations Source: https://context7.com/hazzik/delegatedecompiler/llms.txt Utilize DecompileAsync() with Entity Framework Core 5 and later versions for asynchronous query execution. Ensure DelegateDecompiler.EntityFrameworkCore is referenced. ```csharp using DelegateDecompiler.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; public class Article { public int ArticleId { get; set; } public string Title { get; set; } public string Content { get; set; } public DateTime PublishDate { get; set; } public int ViewCount { get; set; } public int LikeCount { get; set; } public List Comments { get; set; } [Computed] public bool IsPublished => PublishDate <= DateTime.UtcNow; [Computed] public int EngagementScore => ViewCount + (LikeCount * 10); [Computed] public int CommentCount => Comments.Count(); [Computed] public bool IsTrending => EngagementScore > 1000 && CommentCount > 50; } public class ArticleRepository { private readonly BlogDbContext _db; public async Task> GetPublishedArticlesAsync() { return await _db.Articles .Where(a => a.IsPublished) .DecompileAsync() .ToListAsync(); } public async Task> GetTrendingArticlesAsync() { return await _db.Articles .Where(a => a.IsPublished && a.IsTrending) .OrderByDescending(a => a.EngagementScore) .DecompileAsync() .Take(10) .ToListAsync(); } public async Task GetArticleStatsAsync(int articleId) { return await _db.Articles .Where(a => a.ArticleId == articleId) .Select(a => new { a.Title, a.EngagementScore, a.CommentCount, a.IsTrending }) .DecompileAsync() .FirstOrDefaultAsync(); } } ``` -------------------------------- ### Select Abstract Member With Condition Over TPH Hierarchy Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore8.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md Demonstrates applying conditions on abstract members within a TPH hierarchy query. ```SQL SELECT CASE WHEN [l].[Discriminator] = N'WhiteShark' THEN N'Carcharodon carcharias' WHEN [l].[Discriminator] = N'AtlanticCod' THEN N'Gadus morhua' ELSE NULL END AS [Species], CASE WHEN [l].[Discriminator] = N'WhiteShark' THEN N'Fish' WHEN [l].[Discriminator] = N'AtlanticCod' THEN N'Fish' ELSE NULL END AS [Group] FROM [LivingBeeing] AS [l] WHERE [l].[Discriminator] IN (N'AtlanticCod', N'WhiteShark') AND CASE WHEN [l].[Discriminator] = N'WhiteShark' THEN N'Carcharodon carcharias' WHEN [l].[Discriminator] = N'AtlanticCod' THEN N'Gadus morhua' ELSE NULL END IS NOT NULL AND CASE WHEN [l].[Discriminator] = N'WhiteShark' THEN N'Fish' WHEN [l].[Discriminator] = N'AtlanticCod' THEN N'Fish' ELSE NULL END IS NOT NULL ``` -------------------------------- ### Select Abstract Member Over TPH Hierarchy With Generic Classes After Restricting To Subtype Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore9.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md Demonstrates selecting abstract members from a TPH hierarchy with generic classes, after filtering to specific subtypes. ```SQL SELECT CASE WHEN [l].[Discriminator] = N'WhiteShark' THEN N'Carcharodon carcharias' WHEN [l].[Discriminator] = N'AtlanticCod' THEN N'Gadus morhua' END AS [Species], CASE WHEN [l].[Discriminator] = N'WhiteShark' THEN N'Fish' WHEN [l].[Discriminator] = N'AtlanticCod' THEN N'Fish' END AS [Group] FROM [LivingBeeing] AS [l] WHERE [l].[Discriminator] IN (N'AtlanticCod', N'WhiteShark') ``` -------------------------------- ### Convert imperative loops to declarative LINQ Source: https://github.com/hazzik/delegatedecompiler/blob/main/README.md Imperative loops are not supported and will throw exceptions; use declarative LINQ expressions instead. ```csharp var total = 0; foreach (var item in this.Items) { total += item.TotalPrice; } return total; ``` ```csharp return this.Items.Sum(i => i.TotalPrice); ``` -------------------------------- ### Select Abstract Member With Condition On It Over TPH Hierarchy With Generic Classes After Restricting To Subtype Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore9.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md Illustrates selecting abstract members with conditions applied to them, within a TPH hierarchy filtered to specific subtypes. ```SQL SELECT CASE WHEN [l].[Discriminator] = N'WhiteShark' THEN N'Carcharodon carcharias' WHEN [l].[Discriminator] = N'AtlanticCod' THEN N'Gadus morhua' END AS [Species], CASE WHEN [l].[Discriminator] = N'WhiteShark' THEN N'Fish' WHEN [l].[Discriminator] = N'AtlanticCod' THEN N'Fish' END AS [Group] FROM [LivingBeeing] AS [l] WHERE [l].[Discriminator] IN (N'AtlanticCod', N'WhiteShark') AND CASE WHEN [l].[Discriminator] = N'WhiteShark' THEN N'Carcharodon carcharias' WHEN [l].[Discriminator] = N'AtlanticCod' THEN N'Gadus morhua' END IS NOT NULL AND CASE WHEN [l].[Discriminator] = N'WhiteShark' THEN N'Fish' WHEN [l].[Discriminator] = N'AtlanticCod' THEN N'Fish' END IS NOT NULL ``` -------------------------------- ### Select Int Equals Constant Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore9.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md Demonstrates the translation of an integer equality check against a constant into a T-SQL statement that casts the result to a bit. ```SQL SELECT ~CAST([e].[ParentInt] ^ 123 AS bit) FROM [EfParents] AS [e] ``` -------------------------------- ### Nullable Add Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFramework.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md Performs addition on two nullable decimal properties. ```SQL SELECT [Extent1].[ParentNullableDecimal1] + [Extent1].[ParentNullableDecimal2] AS [C1] FROM [dbo].[EfParents] AS [Extent1] ``` -------------------------------- ### Where Any Children Then Order By Then Skip Take Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFramework.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md This T-SQL query filters for parents with children, orders them by child count, skips one, and takes one. It uses EfParents and EfChilds tables. ```SQL SELECT [Project2].[EfParentId] AS [EfParentId] FROM ( SELECT [Extent1].[EfParentId] AS [EfParentId], (SELECT COUNT(1) AS [A1] FROM [dbo].[EfChilds] AS [Extent3] WHERE [Extent1].[EfParentId] = [Extent3].[EfParentId]) AS [C1] FROM [dbo].[EfParents] AS [Extent1] WHERE EXISTS (SELECT 1 AS [C1] FROM [dbo].[EfChilds] AS [Extent2] WHERE [Extent1].[EfParentId] = [Extent2].[EfParentId] ) ) AS [Project2] ORDER BY row_number() OVER (ORDER BY [Project2].[C1] ASC) OFFSET 1 ROWS FETCH NEXT 1 ROWS ONLY ``` -------------------------------- ### AddDelegateDecompiler() - Automatic Decompilation Source: https://context7.com/hazzik/delegatedecompiler/llms.txt Configures Entity Framework Core to automatically decompile all queries, eliminating the need to call Decompile() or DecompileAsync() on each query. ```APIDOC ## AddDelegateDecompiler() ### Description Configures Entity Framework Core to automatically decompile all queries, eliminating the need to call `Decompile()` or `DecompileAsync()` on each query. ### Method Extension method for `DbContextOptionsBuilder`. ### Endpoint N/A (Configuration method) ### Parameters None ### Request Example ```csharp protected override void OnConfiguring(DbContextOptionsBuilder options) { options .UseSqlServer("your-connection-string") .AddDelegateDecompiler(); // Enable automatic decompilation } ``` ### Response N/A (Configuration) ### Response Example N/A ``` -------------------------------- ### Decompile MethodInfo to LambdaExpression Source: https://context7.com/hazzik/delegatedecompiler/llms.txt Converts a MethodInfo object into a LambdaExpression, allowing programmatic access to method implementations. Requires DelegateDecompiler and System.Reflection. ```csharp using DelegateDecompiler; using System.Reflection; using System.Linq.Expressions; public class Calculator { public int Square(int x) => x * x; public bool IsEven(int x) => x % 2 == 0; public string Format(int x) => "Value: " + x.ToString(); } // Get MethodInfo and decompile var squareMethod = typeof(Calculator).GetMethod("Square"); LambdaExpression squareExpr = squareMethod.Decompile(); // Result: (Calculator this, int x) => x * x ``` -------------------------------- ### Property Is Null Query Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore8.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md SQL generated to check if a nullable integer property is null. ```SQL SELECT CASE WHEN [e].[ParentNullableInt] IS NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [EfParents] AS [e] ``` -------------------------------- ### Decompile Computed Properties with IQueryable Source: https://context7.com/hazzik/delegatedecompiler/llms.txt Use the `Decompile()` extension method before materialization to decompile computed properties in your IQueryable queries. It supports various LINQ operations like Where, Select, Count, and OrderBy. ```csharp using DelegateDecompiler; using System.Linq; public class Order { public int OrderId { get; set; } public DateTime OrderDate { get; set; } public decimal Subtotal { get; set; } public decimal TaxRate { get; set; } public decimal ShippingCost { get; set; } public List Items { get; set; } [Computed] public decimal TaxAmount => Subtotal * TaxRate; [Computed] public decimal Total => Subtotal + TaxAmount + ShippingCost; [Computed] public int ItemCount => Items.Count(); [Computed] public bool IsLargeOrder => ItemCount > 10; } using (var db = new MyDbContext()) { // Basic usage - call Decompile() before ToList() var orders = db.Orders .Where(o => o.Total > 500) .Decompile() .ToList(); // Works with Select projections var orderSummaries = db.Orders .Select(o => new { o.OrderId, o.Total, o.TaxAmount, o.IsLargeOrder }) .Decompile() .ToList(); // Works with aggregation methods var largeOrderCount = db.Orders .Decompile() .Count(o => o.IsLargeOrder); // Works with First, Single, Any, etc. var firstBigOrder = db.Orders .Where(o => o.Total > 1000) .Decompile() .FirstOrDefault(); bool hasExpensiveOrders = db.Orders .Decompile() .Any(o => o.Total > 5000); // Works with OrderBy var sortedOrders = db.Orders .OrderByDescending(o => o.Total) .Decompile() .Take(10) .ToList(); } ``` -------------------------------- ### Decompile computed properties in LINQ queries Source: https://github.com/hazzik/delegatedecompiler/blob/main/README.md Apply the .Decompile() extension method to translate computed properties into their underlying logic for database execution. ```csharp var employees = (from employee in db.Employees where employee.FullName == "Test User" select employee).Decompile().ToList(); ``` ```csharp var employees = (from employee in db.Employees where (employee.FirstName + " " + employee.LastName) == "Test User" select employee).ToList(); ``` -------------------------------- ### All Quantifier T-SQL Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFramework.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md Generates NOT EXISTS clauses to verify that all elements satisfy a given condition. ```SQL SELECT CASE WHEN ( NOT EXISTS (SELECT 1 AS [C1] FROM [dbo].[EfParents] AS [Extent1] WHERE (123 <> [Extent1].[ParentInt]) OR (CASE WHEN (123 = [Extent1].[ParentInt]) THEN cast(1 as bit) WHEN (123 <> [Extent1].[ParentInt]) THEN cast(0 as bit) END IS NULL) )) THEN cast(1 as bit) ELSE cast(0 as bit) END AS [C1] FROM ( SELECT 1 AS X ) AS [SingleRowTable1] ``` ```SQL SELECT CASE WHEN ( NOT EXISTS (SELECT 1 AS [C1] FROM [dbo].[EfChilds] AS [Extent2] WHERE ([Extent1].[EfParentId] = [Extent2].[EfParentId]) AND ((123 <> [Extent2].[ChildInt]) OR (CASE WHEN (123 = [Extent2].[ChildInt]) THEN cast(1 as bit) WHEN (123 <> [Extent2].[ChildInt]) THEN cast(0 as bit) END IS NULL)) )) THEN cast(1 as bit) ELSE cast(0 as bit) END AS [C1] FROM [dbo].[EfParents] AS [Extent1] ``` -------------------------------- ### Singleton Count Children With Filter Async T-SQL Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFramework.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md This T-SQL query first counts children for each parent, then filters these counts to find parents where the child count equals 2, and finally returns a single aggregated count. Use when needing a single aggregated result based on a condition applied to child counts. ```SQL SELECT [GroupBy2].[A1] AS [C1] FROM ( SELECT COUNT(1) AS [A1] FROM ( SELECT (SELECT COUNT(1) AS [A1] FROM [dbo].[EfChilds] AS [Extent2] WHERE [Extent1].[EfParentId] = [Extent2].[EfParentId]) AS [C1] FROM [dbo].[EfParents] AS [Extent1] ) AS [Project1] WHERE 2 = [Project1].[C1] ) AS [GroupBy2] ``` -------------------------------- ### Nullable Int Equals Constant Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFramework.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md Compares a nullable integer property to a constant, treating nulls as zero. ```SQL SELECT CASE WHEN (123 = (CASE WHEN ([Extent1].[ParentNullableInt] IS NULL) THEN 0 ELSE [Extent1].[ParentNullableInt] END)) THEN cast(1 as bit) WHEN ( NOT ((123 = (CASE WHEN ([Extent1].[ParentNullableInt] IS NULL) THEN 0 ELSE [Extent1].[ParentNullableInt] END)) AND (CASE WHEN ([Extent1].[ParentNullableInt] IS NULL) THEN 0 ELSE [Extent1].[ParentNullableInt] END IS NOT NULL))) THEN cast(0 as bit) END AS [C1] FROM [dbo].[EfParents] AS [Extent1] ``` -------------------------------- ### Decompile methods in LINQ queries Source: https://github.com/hazzik/delegatedecompiler/blob/main/README.md Methods like Any, Count, First, or Single can be decompiled to allow complex logic within database queries. ```csharp bool exists = db.Employees.Decompile().Any(employee => employee.FullName == "Test User"); ``` ```csharp bool exists = db.Employees.Any(employee => (employee.FirstName + " " + employee.LastName) == "Test User"); ``` -------------------------------- ### Select Bool Equals Static Variable Source: https://github.com/hazzik/delegatedecompiler/blob/main/src/DelegateDecompiler.EntityFrameworkCore9.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md Converts a boolean equality check against a static variable into a T-SQL query using XOR and bitwise NOT operations. ```SQL SELECT ~([e].[ParentBool] ^ @__staticBool_0) FROM [EfParents] AS [e] ```