public void TestLocate_Field_ThrowsForNonExistentFields()
        {
            // Arrange
            var tModel = ModelFixture.Create();
            var ast    = KayleeHelper.Parse(tModel);
            var user   = ast.Locate("auth", new[] { "User" });

            // Act & Assert
            Assert.Throws <FieldNotFoundException>(() => user.Locate("VoidField"));
        }
Exemple #2
0
        public void TestGetModelName()
        {
            // Arrange
            var tSchema  = AuthSchemaFixture.Create();
            var ast      = KayleeHelper.Parse(tSchema);
            var userRole = ast.Locate("auth", new[] { "User", "Role" });
            // Act
            var modelName = userRole.GetModelName();

            // Assert
            Assert.Equal("UserRole", modelName);
        }
Exemple #3
0
        public void TestHasDefault(bool expected, string fieldName)
        {
            // Arrange
            var tSchema = AuthSchemaFixture.Create();
            var ast     = KayleeHelper.Parse(tSchema);
            var user    = ast.Locate("auth", new[] { "User" });
            var field   = user.Locate(fieldName);
            // Act
            var hasDefault = field.HasDefault();

            // Assert
            Assert.Equal(expected, hasDefault);
        }
        public void TestLocate_Field()
        {
            // Arrange
            var tModel    = ModelFixture.Create();
            var ast       = KayleeHelper.Parse(tModel);
            var user      = ast.Locate("auth", new[] { "User" });
            var fieldName = "UserId";
            var userId    = user.Fields.Single(f => f.Name == fieldName);
            // Act
            var field = user.Locate(fieldName);

            // Assert
            Assert.Equal(userId, field);
        }
        public void TestLocate_Field_PartOfParentKey()
        {
            // Arrange
            var tModel          = ModelFixture.Create();
            var ast             = KayleeHelper.Parse(tModel);
            var tenantProcedure = ast.Locate("tenant", new[] { "Tenant", "Procedure" });
            var fieldName       = "TenantId";
            var tenantId        = tenantProcedure.Parent.Fields.Single(f => f.Name == fieldName);
            // Act
            var field = tenantProcedure.Locate(fieldName);

            // Assert
            Assert.Equal(tenantId, field);
        }
        public void TestGetFullPrimaryKey()
        {
            // Arrange
            var tModel    = ModelFixture.Create();
            var ast       = KayleeHelper.Parse(tModel);
            var procedure = ast.Locate("tenant", new[] { "Tenant", "Procedure" });
            // Act
            var fullPrimaryKey = procedure.GetFullPrimaryKey();
            // Assert
            var expected = new[] {
                procedure.Parent.PrimaryKey.Single(),
                procedure.PrimaryKey.Single()
            };

            Assert.Equal(expected, fullPrimaryKey);
        }
        private Ast?ParseModel(GeneratorExecutionContext context)
        {
            var model = ReadModel(context);

            if (model == null)
            {
                return(null);
            }
            try
            {
                return(KayleeHelper.Parse(model));
            }
            catch (ParseException e)
            {
                context.ReportDiagnostic(Diagnostic.Create(FailedToParseError, Location.None, e.ToString()));
                return(null);
            }
        }
Exemple #8
0
        public async Task TestWrite()
        {
            // Arrange
            var tSchema = AuthSchemaFixture.Create();
            var ast     = KayleeHelper.Parse(tSchema);
            // Act
            var source = QueriesWriter.Write(ast);
            // Assert
            await DebugUtils.WriteGeneratedFileToDisk("Queries.cs", source).ConfigureAwait(false);

            Assert.Equal(@"#nullable enable

using System.Linq;

namespace Allvis.Kaylee.Generated.SqlKata
{
    public static class Queries
    {
        public static global::SqlKata.Query Exists_auth_User(global::System.Guid userId)
        {
            return new global::SqlKata.Query(""auth.v_User"")
                .Where(""UserId"", userId)
                .SelectRaw(""1"")
                .Limit(1);
        }
        public static global::SqlKata.Query Exists_auth_User_UK_ContactEmail(string contactEmail)
        {
            return new global::SqlKata.Query(""auth.v_User"")
                .Where(""ContactEmail"", contactEmail)
                .SelectRaw(""1"")
                .Limit(1);
        }
        public static global::SqlKata.Query Exists_auth_User_UK_NormalizedContactEmail(string normalizedContactEmail)
        {
            return new global::SqlKata.Query(""auth.v_User"")
                .Where(""NormalizedContactEmail"", normalizedContactEmail)
                .SelectRaw(""1"")
                .Limit(1);
        }
        public static global::SqlKata.Query Exists_auth_User_UK_Hash_RAM4(byte[] hash, long rAM4)
        {
            return new global::SqlKata.Query(""auth.v_User"")
                .Where(""Hash"", hash)
                .Where(""RAM4"", rAM4)
                .SelectRaw(""1"")
                .Limit(1);
        }
        public static global::SqlKata.Query Count_auth_User()
        {
            return new global::SqlKata.Query(""auth.v_User"")
                .AsCount();
        }
        public static global::SqlKata.Query Get_auth_User(global::System.Guid userId)
        {
            return new global::SqlKata.Query(""auth.v_User"")
                .Where(""UserId"", userId)
                .Select(""UserId"")
                .Select(""FirstName"")
                .Select(""LastName"")
                .Select(""ContactEmail"")
                .Select(""NormalizedContactEmail"")
                .Select(""Hash"")
                .Select(""Picture"")
                .Select(""ETag"")
                .Select(""RAM4"")
                .Select(""Price"");
        }
        public static global::SqlKata.Query Get_auth_User()
        {
            return new global::SqlKata.Query(""auth.v_User"")
                .Select(""UserId"")
                .Select(""FirstName"")
                .Select(""LastName"")
                .Select(""ContactEmail"")
                .Select(""NormalizedContactEmail"")
                .Select(""Hash"")
                .Select(""Picture"")
                .Select(""ETag"")
                .Select(""RAM4"")
                .Select(""Price"");
        }
        public static global::SqlKata.Query Get_auth_User_UK_ContactEmail(string contactEmail)
        {
            return new global::SqlKata.Query(""auth.v_User"")
                .Where(""ContactEmail"", contactEmail)
                .Select(""UserId"")
                .Select(""FirstName"")
                .Select(""LastName"")
                .Select(""ContactEmail"")
                .Select(""NormalizedContactEmail"")
                .Select(""Hash"")
                .Select(""Picture"")
                .Select(""ETag"")
                .Select(""RAM4"")
                .Select(""Price"");
        }
        public static global::SqlKata.Query Get_auth_User_UK_NormalizedContactEmail(string normalizedContactEmail)
        {
            return new global::SqlKata.Query(""auth.v_User"")
                .Where(""NormalizedContactEmail"", normalizedContactEmail)
                .Select(""UserId"")
                .Select(""FirstName"")
                .Select(""LastName"")
                .Select(""ContactEmail"")
                .Select(""NormalizedContactEmail"")
                .Select(""Hash"")
                .Select(""Picture"")
                .Select(""ETag"")
                .Select(""RAM4"")
                .Select(""Price"");
        }
        public static global::SqlKata.Query Get_auth_User_UK_Hash_RAM4(byte[] hash, long rAM4)
        {
            return new global::SqlKata.Query(""auth.v_User"")
                .Where(""Hash"", hash)
                .Where(""RAM4"", rAM4)
                .Select(""UserId"")
                .Select(""FirstName"")
                .Select(""LastName"")
                .Select(""ContactEmail"")
                .Select(""NormalizedContactEmail"")
                .Select(""Hash"")
                .Select(""Picture"")
                .Select(""ETag"")
                .Select(""RAM4"")
                .Select(""Price"");
        }
        public static global::SqlKata.Query Insert_auth_User(global::System.Guid? userId, string? firstName, string? lastName, string contactEmail, byte[] hash, byte[]? picture, long rAM4, decimal price)
        {
            var _columns = new global::System.Collections.Generic.List<string>();
            var _values = new global::System.Collections.Generic.List<object?>();
            if (userId != null)
            {
                _columns.Add(""UserId"");
                _values.Add(userId);
            }
            if (firstName != null)
            {
                _columns.Add(""FirstName"");
                _values.Add(firstName);
            }
            if (lastName != null)
            {
                _columns.Add(""LastName"");
                _values.Add(lastName);
            }
            _columns.Add(""ContactEmail"");
            _values.Add(contactEmail);
            _columns.Add(""Hash"");
            _values.Add(hash);
            if (picture != null)
            {
                _columns.Add(""Picture"");
                _values.Add(picture);
            }
            _columns.Add(""RAM4"");
            _values.Add(rAM4);
            _columns.Add(""Price"");
            _values.Add(price);
            return new global::SqlKata.Query(""auth.tbl_User"")
                .AsInsert(_columns, _values);
        }
        public static global::SqlKata.Query Insert_auth_User(global::System.Collections.Generic.IEnumerable<(global::System.Guid UserId, string? FirstName, string? LastName, string ContactEmail, byte[] Hash, byte[]? Picture, long RAM4, decimal Price)> rows)
        {
            var _columns = new string[] {
                ""UserId"",
                ""FirstName"",
                ""LastName"",
                ""ContactEmail"",
                ""Hash"",
                ""Picture"",
                ""RAM4"",
                ""Price""
            };
            var _values = rows.Select(_row => new object?[] {
                _row.UserId,
                _row.FirstName,
                _row.LastName,
                _row.ContactEmail,
                _row.Hash,
                _row.Picture,
                _row.RAM4,
                _row.Price
            });
            return new global::SqlKata.Query(""auth.tbl_User"")
                .AsInsert(_columns, _values);
        }
        public static global::SqlKata.Query Delete_auth_User(global::System.Guid userId)
        {
            return new global::SqlKata.Query(""auth.tbl_User"")
                .Where(""UserId"", userId)
                .AsDelete();
        }
        public static global::SqlKata.Query Delete_auth_User()
        {
            return new global::SqlKata.Query(""auth.tbl_User"")
                .AsDelete();
        }
        public static global::SqlKata.Query Delete_auth_User_UK_ContactEmail(string contactEmail)
        {
            return new global::SqlKata.Query(""auth.tbl_User"")
                .Where(""ContactEmail"", contactEmail)
                .AsDelete();
        }
        public static global::SqlKata.Query Delete_auth_User_UK_NormalizedContactEmail(string normalizedContactEmail)
        {
            return new global::SqlKata.Query(""auth.tbl_User"")
                .Where(""NormalizedContactEmail"", normalizedContactEmail)
                .AsDelete();
        }
        public static global::SqlKata.Query Delete_auth_User_UK_Hash_RAM4(byte[] hash, long rAM4)
        {
            return new global::SqlKata.Query(""auth.tbl_User"")
                .Where(""Hash"", hash)
                .Where(""RAM4"", rAM4)
                .AsDelete();
        }
        public static global::SqlKata.Query Update_auth_User_FullName(global::System.Guid k_UserId, string? firstName, string? lastName)
        {
            var _columns = new string[] {
                ""FirstName"",
                ""LastName""
            };
            var _values = new object?[] {
                firstName,
                lastName
            };
            return new global::SqlKata.Query(""auth.tbl_User"")
                .Where(""UserId"", k_UserId)
                .AsUpdate(_columns, _values);
        }
        public static global::SqlKata.Query Update_auth_User_FullName_UK_ContactEmail(string k_ContactEmail, string? firstName, string? lastName)
        {
            var _columns = new string[] {
                ""FirstName"",
                ""LastName""
            };
            var _values = new object?[] {
                firstName,
                lastName
            };
            return new global::SqlKata.Query(""auth.tbl_User"")
                .Where(""ContactEmail"", k_ContactEmail)
                .AsUpdate(_columns, _values);
        }
        public static global::SqlKata.Query Update_auth_User_FullName_UK_NormalizedContactEmail(string k_NormalizedContactEmail, string? firstName, string? lastName)
        {
            var _columns = new string[] {
                ""FirstName"",
                ""LastName""
            };
            var _values = new object?[] {
                firstName,
                lastName
            };
            return new global::SqlKata.Query(""auth.tbl_User"")
                .Where(""NormalizedContactEmail"", k_NormalizedContactEmail)
                .AsUpdate(_columns, _values);
        }
        public static global::SqlKata.Query Update_auth_User_FullName_UK_Hash_RAM4(byte[] k_Hash, long k_RAM4, string? firstName, string? lastName)
        {
            var _columns = new string[] {
                ""FirstName"",
                ""LastName""
            };
            var _values = new object?[] {
                firstName,
                lastName
            };
            return new global::SqlKata.Query(""auth.tbl_User"")
                .Where(""Hash"", k_Hash)
                .Where(""RAM4"", k_RAM4)
                .AsUpdate(_columns, _values);
        }
        public static global::SqlKata.Query Update_auth_User_ContactInformation(global::System.Guid k_UserId, string contactEmail)
        {
            var _columns = new string[] {
                ""ContactEmail""
            };
            var _values = new object?[] {
                contactEmail
            };
            return new global::SqlKata.Query(""auth.tbl_User"")
                .Where(""UserId"", k_UserId)
                .AsUpdate(_columns, _values);
        }
        public static global::SqlKata.Query Update_auth_User_ContactInformation_UK_ContactEmail(string k_ContactEmail, string contactEmail)
        {
            var _columns = new string[] {
                ""ContactEmail""
            };
            var _values = new object?[] {
                contactEmail
            };
            return new global::SqlKata.Query(""auth.tbl_User"")
                .Where(""ContactEmail"", k_ContactEmail)
                .AsUpdate(_columns, _values);
        }
        public static global::SqlKata.Query Update_auth_User_ContactInformation_UK_NormalizedContactEmail(string k_NormalizedContactEmail, string contactEmail)
        {
            var _columns = new string[] {
                ""ContactEmail""
            };
            var _values = new object?[] {
                contactEmail
            };
            return new global::SqlKata.Query(""auth.tbl_User"")
                .Where(""NormalizedContactEmail"", k_NormalizedContactEmail)
                .AsUpdate(_columns, _values);
        }
        public static global::SqlKata.Query Update_auth_User_ContactInformation_UK_Hash_RAM4(byte[] k_Hash, long k_RAM4, string contactEmail)
        {
            var _columns = new string[] {
                ""ContactEmail""
            };
            var _values = new object?[] {
                contactEmail
            };
            return new global::SqlKata.Query(""auth.tbl_User"")
                .Where(""Hash"", k_Hash)
                .Where(""RAM4"", k_RAM4)
                .AsUpdate(_columns, _values);
        }
        public static global::SqlKata.Query Exists_auth_UserTask(global::System.Guid userId, int taskId)
        {
            return new global::SqlKata.Query(""auth.v_UserTask"")
                .Where(""UserId"", userId)
                .Where(""TaskId"", taskId)
                .SelectRaw(""1"")
                .Limit(1);
        }
        public static global::SqlKata.Query Count_auth_UserTask_GroupBy_UserId()
        {
            return new global::SqlKata.Query(""auth.v_UserTask"")
                .GroupBy(""UserId"")
                .Select(""UserId"")
                .SelectRaw(""COUNT(*) as Count"");
        }
        public static global::SqlKata.Query Count_auth_UserTask(global::System.Guid userId)
        {
            return new global::SqlKata.Query(""auth.v_UserTask"")
                .Where(""UserId"", userId)
                .AsCount();
        }
        public static global::SqlKata.Query Count_auth_UserTask()
        {
            return new global::SqlKata.Query(""auth.v_UserTask"")
                .AsCount();
        }
        public static global::SqlKata.Query Get_auth_UserTask(global::System.Guid userId, int taskId)
        {
            return new global::SqlKata.Query(""auth.v_UserTask"")
                .Where(""UserId"", userId)
                .Where(""TaskId"", taskId)
                .Select(""UserId"")
                .Select(""TaskId"")
                .Select(""Todo"");
        }
        public static global::SqlKata.Query Get_auth_UserTask(global::System.Guid userId)
        {
            return new global::SqlKata.Query(""auth.v_UserTask"")
                .Where(""UserId"", userId)
                .Select(""UserId"")
                .Select(""TaskId"")
                .Select(""Todo"");
        }
        public static global::SqlKata.Query Get_auth_UserTask()
        {
            return new global::SqlKata.Query(""auth.v_UserTask"")
                .Select(""UserId"")
                .Select(""TaskId"")
                .Select(""Todo"");
        }
        public static global::SqlKata.Query Exists_auth_UserRole(global::System.Guid userId, global::System.Guid roleId)
        {
            return new global::SqlKata.Query(""auth.v_UserRole"")
                .Where(""UserId"", userId)
                .Where(""RoleId"", roleId)
                .SelectRaw(""1"")
                .Limit(1);
        }
        public static global::SqlKata.Query Count_auth_UserRole_GroupBy_UserId()
        {
            return new global::SqlKata.Query(""auth.v_UserRole"")
                .GroupBy(""UserId"")
                .Select(""UserId"")
                .SelectRaw(""COUNT(*) as Count"");
        }
        public static global::SqlKata.Query Count_auth_UserRole(global::System.Guid userId)
        {
            return new global::SqlKata.Query(""auth.v_UserRole"")
                .Where(""UserId"", userId)
                .AsCount();
        }
        public static global::SqlKata.Query Count_auth_UserRole()
        {
            return new global::SqlKata.Query(""auth.v_UserRole"")
                .AsCount();
        }
        public static global::SqlKata.Query Get_auth_UserRole(global::System.Guid userId, global::System.Guid roleId)
        {
            return new global::SqlKata.Query(""auth.v_UserRole"")
                .Where(""UserId"", userId)
                .Where(""RoleId"", roleId)
                .Select(""UserId"")
                .Select(""RoleId"")
                .Select(""Flag"");
        }
        public static global::SqlKata.Query Get_auth_UserRole(global::System.Guid userId)
        {
            return new global::SqlKata.Query(""auth.v_UserRole"")
                .Where(""UserId"", userId)
                .Select(""UserId"")
                .Select(""RoleId"")
                .Select(""Flag"");
        }
        public static global::SqlKata.Query Get_auth_UserRole()
        {
            return new global::SqlKata.Query(""auth.v_UserRole"")
                .Select(""UserId"")
                .Select(""RoleId"")
                .Select(""Flag"");
        }
        public static global::SqlKata.Query Insert_auth_UserRole(global::System.Guid userId, global::System.Guid roleId, int? flag)
        {
            var _columns = new global::System.Collections.Generic.List<string>();
            var _values = new global::System.Collections.Generic.List<object?>();
            _columns.Add(""UserId"");
            _values.Add(userId);
            _columns.Add(""RoleId"");
            _values.Add(roleId);
            if (flag != null)
            {
                _columns.Add(""Flag"");
                _values.Add(flag);
            }
            return new global::SqlKata.Query(""auth.tbl_UserRole"")
                .AsInsert(_columns, _values);
        }
        public static global::SqlKata.Query Insert_auth_UserRole(global::System.Collections.Generic.IEnumerable<(global::System.Guid UserId, global::System.Guid RoleId, int Flag)> rows)
        {
            var _columns = new string[] {
                ""UserId"",
                ""RoleId"",
                ""Flag""
            };
            var _values = rows.Select(_row => new object?[] {
                _row.UserId,
                _row.RoleId,
                _row.Flag
            });
            return new global::SqlKata.Query(""auth.tbl_UserRole"")
                .AsInsert(_columns, _values);
        }
        public static global::SqlKata.Query Delete_auth_UserRole(global::System.Guid userId, global::System.Guid roleId)
        {
            return new global::SqlKata.Query(""auth.tbl_UserRole"")
                .Where(""UserId"", userId)
                .Where(""RoleId"", roleId)
                .AsDelete();
        }
        public static global::SqlKata.Query Delete_auth_UserRole(global::System.Guid userId)
        {
            return new global::SqlKata.Query(""auth.tbl_UserRole"")
                .Where(""UserId"", userId)
                .AsDelete();
        }
        public static global::SqlKata.Query Delete_auth_UserRole()
        {
            return new global::SqlKata.Query(""auth.tbl_UserRole"")
                .AsDelete();
        }
        public static global::SqlKata.Query Update_auth_UserRole_Flag(global::System.Guid k_UserId, global::System.Guid k_RoleId, int flag)
        {
            var _columns = new string[] {
                ""Flag""
            };
            var _values = new object?[] {
                flag
            };
            return new global::SqlKata.Query(""auth.tbl_UserRole"")
                .Where(""UserId"", k_UserId)
                .Where(""RoleId"", k_RoleId)
                .AsUpdate(_columns, _values);
        }
        public static global::SqlKata.Query Exists_auth_UserRoleLog(global::System.Guid userId, global::System.Guid roleId, int logId)
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLog"")
                .Where(""UserId"", userId)
                .Where(""RoleId"", roleId)
                .Where(""LogId"", logId)
                .SelectRaw(""1"")
                .Limit(1);
        }
        public static global::SqlKata.Query Count_auth_UserRoleLog_GroupBy_UserId_RoleId(global::System.Guid userId)
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLog"")
                .Where(""UserId"", userId)
                .GroupBy(""UserId"")
                .GroupBy(""RoleId"")
                .Select(""UserId"")
                .Select(""RoleId"")
                .SelectRaw(""COUNT(*) as Count"");
        }
        public static global::SqlKata.Query Count_auth_UserRoleLog_GroupBy_UserId_RoleId()
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLog"")
                .GroupBy(""UserId"")
                .GroupBy(""RoleId"")
                .Select(""UserId"")
                .Select(""RoleId"")
                .SelectRaw(""COUNT(*) as Count"");
        }
        public static global::SqlKata.Query Count_auth_UserRoleLog(global::System.Guid userId, global::System.Guid roleId)
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLog"")
                .Where(""UserId"", userId)
                .Where(""RoleId"", roleId)
                .AsCount();
        }
        public static global::SqlKata.Query Count_auth_UserRoleLog_GroupBy_UserId()
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLog"")
                .GroupBy(""UserId"")
                .Select(""UserId"")
                .SelectRaw(""COUNT(*) as Count"");
        }
        public static global::SqlKata.Query Count_auth_UserRoleLog(global::System.Guid userId)
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLog"")
                .Where(""UserId"", userId)
                .AsCount();
        }
        public static global::SqlKata.Query Count_auth_UserRoleLog()
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLog"")
                .AsCount();
        }
        public static global::SqlKata.Query Get_auth_UserRoleLog(global::System.Guid userId, global::System.Guid roleId, int logId)
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLog"")
                .Where(""UserId"", userId)
                .Where(""RoleId"", roleId)
                .Where(""LogId"", logId)
                .Select(""UserId"")
                .Select(""RoleId"")
                .Select(""LogId"")
                .Select(""Content"");
        }
        public static global::SqlKata.Query Get_auth_UserRoleLog(global::System.Guid userId, global::System.Guid roleId)
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLog"")
                .Where(""UserId"", userId)
                .Where(""RoleId"", roleId)
                .Select(""UserId"")
                .Select(""RoleId"")
                .Select(""LogId"")
                .Select(""Content"");
        }
        public static global::SqlKata.Query Get_auth_UserRoleLog(global::System.Guid userId)
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLog"")
                .Where(""UserId"", userId)
                .Select(""UserId"")
                .Select(""RoleId"")
                .Select(""LogId"")
                .Select(""Content"");
        }
        public static global::SqlKata.Query Get_auth_UserRoleLog()
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLog"")
                .Select(""UserId"")
                .Select(""RoleId"")
                .Select(""LogId"")
                .Select(""Content"");
        }
        public static global::SqlKata.Query Insert_auth_UserRoleLog(global::System.Guid userId, global::System.Guid roleId, string content)
        {
            var _columns = new global::System.Collections.Generic.List<string>();
            var _values = new global::System.Collections.Generic.List<object?>();
            _columns.Add(""UserId"");
            _values.Add(userId);
            _columns.Add(""RoleId"");
            _values.Add(roleId);
            _columns.Add(""Content"");
            _values.Add(content);
            return new global::SqlKata.Query(""auth.tbl_UserRoleLog"")
                .AsInsert(_columns, _values);
        }
        public static global::SqlKata.Query Insert_auth_UserRoleLog(global::System.Collections.Generic.IEnumerable<(global::System.Guid UserId, global::System.Guid RoleId, string Content)> rows)
        {
            var _columns = new string[] {
                ""UserId"",
                ""RoleId"",
                ""Content""
            };
            var _values = rows.Select(_row => new object?[] {
                _row.UserId,
                _row.RoleId,
                _row.Content
            });
            return new global::SqlKata.Query(""auth.tbl_UserRoleLog"")
                .AsInsert(_columns, _values);
        }
        public static global::SqlKata.Query Delete_auth_UserRoleLog(global::System.Guid userId, global::System.Guid roleId, int logId)
        {
            return new global::SqlKata.Query(""auth.tbl_UserRoleLog"")
                .Where(""UserId"", userId)
                .Where(""RoleId"", roleId)
                .Where(""LogId"", logId)
                .AsDelete();
        }
        public static global::SqlKata.Query Delete_auth_UserRoleLog(global::System.Guid userId, global::System.Guid roleId)
        {
            return new global::SqlKata.Query(""auth.tbl_UserRoleLog"")
                .Where(""UserId"", userId)
                .Where(""RoleId"", roleId)
                .AsDelete();
        }
        public static global::SqlKata.Query Delete_auth_UserRoleLog(global::System.Guid userId)
        {
            return new global::SqlKata.Query(""auth.tbl_UserRoleLog"")
                .Where(""UserId"", userId)
                .AsDelete();
        }
        public static global::SqlKata.Query Delete_auth_UserRoleLog()
        {
            return new global::SqlKata.Query(""auth.tbl_UserRoleLog"")
                .AsDelete();
        }
        public static global::SqlKata.Query Exists_auth_UserRoleLogTrace(global::System.Guid userId, global::System.Guid roleId, int logId, global::System.Guid traceId)
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLogTrace"")
                .Where(""UserId"", userId)
                .Where(""RoleId"", roleId)
                .Where(""LogId"", logId)
                .Where(""TraceId"", traceId)
                .SelectRaw(""1"")
                .Limit(1);
        }
        public static global::SqlKata.Query Count_auth_UserRoleLogTrace_GroupBy_UserId_RoleId_LogId(global::System.Guid userId, global::System.Guid roleId)
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLogTrace"")
                .Where(""UserId"", userId)
                .Where(""RoleId"", roleId)
                .GroupBy(""UserId"")
                .GroupBy(""RoleId"")
                .GroupBy(""LogId"")
                .Select(""UserId"")
                .Select(""RoleId"")
                .Select(""LogId"")
                .SelectRaw(""COUNT(*) as Count"");
        }
        public static global::SqlKata.Query Count_auth_UserRoleLogTrace_GroupBy_UserId_RoleId_LogId(global::System.Guid userId)
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLogTrace"")
                .Where(""UserId"", userId)
                .GroupBy(""UserId"")
                .GroupBy(""RoleId"")
                .GroupBy(""LogId"")
                .Select(""UserId"")
                .Select(""RoleId"")
                .Select(""LogId"")
                .SelectRaw(""COUNT(*) as Count"");
        }
        public static global::SqlKata.Query Count_auth_UserRoleLogTrace_GroupBy_UserId_RoleId_LogId()
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLogTrace"")
                .GroupBy(""UserId"")
                .GroupBy(""RoleId"")
                .GroupBy(""LogId"")
                .Select(""UserId"")
                .Select(""RoleId"")
                .Select(""LogId"")
                .SelectRaw(""COUNT(*) as Count"");
        }
        public static global::SqlKata.Query Count_auth_UserRoleLogTrace(global::System.Guid userId, global::System.Guid roleId, int logId)
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLogTrace"")
                .Where(""UserId"", userId)
                .Where(""RoleId"", roleId)
                .Where(""LogId"", logId)
                .AsCount();
        }
        public static global::SqlKata.Query Count_auth_UserRoleLogTrace_GroupBy_UserId_RoleId(global::System.Guid userId)
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLogTrace"")
                .Where(""UserId"", userId)
                .GroupBy(""UserId"")
                .GroupBy(""RoleId"")
                .Select(""UserId"")
                .Select(""RoleId"")
                .SelectRaw(""COUNT(*) as Count"");
        }
        public static global::SqlKata.Query Count_auth_UserRoleLogTrace_GroupBy_UserId_RoleId()
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLogTrace"")
                .GroupBy(""UserId"")
                .GroupBy(""RoleId"")
                .Select(""UserId"")
                .Select(""RoleId"")
                .SelectRaw(""COUNT(*) as Count"");
        }
        public static global::SqlKata.Query Count_auth_UserRoleLogTrace(global::System.Guid userId, global::System.Guid roleId)
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLogTrace"")
                .Where(""UserId"", userId)
                .Where(""RoleId"", roleId)
                .AsCount();
        }
        public static global::SqlKata.Query Count_auth_UserRoleLogTrace_GroupBy_UserId()
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLogTrace"")
                .GroupBy(""UserId"")
                .Select(""UserId"")
                .SelectRaw(""COUNT(*) as Count"");
        }
        public static global::SqlKata.Query Count_auth_UserRoleLogTrace(global::System.Guid userId)
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLogTrace"")
                .Where(""UserId"", userId)
                .AsCount();
        }
        public static global::SqlKata.Query Count_auth_UserRoleLogTrace()
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLogTrace"")
                .AsCount();
        }
        public static global::SqlKata.Query Get_auth_UserRoleLogTrace(global::System.Guid userId, global::System.Guid roleId, int logId, global::System.Guid traceId)
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLogTrace"")
                .Where(""UserId"", userId)
                .Where(""RoleId"", roleId)
                .Where(""LogId"", logId)
                .Where(""TraceId"", traceId)
                .Select(""UserId"")
                .Select(""RoleId"")
                .Select(""LogId"")
                .Select(""TraceId"");
        }
        public static global::SqlKata.Query Get_auth_UserRoleLogTrace(global::System.Guid userId, global::System.Guid roleId, int logId)
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLogTrace"")
                .Where(""UserId"", userId)
                .Where(""RoleId"", roleId)
                .Where(""LogId"", logId)
                .Select(""UserId"")
                .Select(""RoleId"")
                .Select(""LogId"")
                .Select(""TraceId"");
        }
        public static global::SqlKata.Query Get_auth_UserRoleLogTrace(global::System.Guid userId, global::System.Guid roleId)
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLogTrace"")
                .Where(""UserId"", userId)
                .Where(""RoleId"", roleId)
                .Select(""UserId"")
                .Select(""RoleId"")
                .Select(""LogId"")
                .Select(""TraceId"");
        }
        public static global::SqlKata.Query Get_auth_UserRoleLogTrace(global::System.Guid userId)
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLogTrace"")
                .Where(""UserId"", userId)
                .Select(""UserId"")
                .Select(""RoleId"")
                .Select(""LogId"")
                .Select(""TraceId"");
        }
        public static global::SqlKata.Query Get_auth_UserRoleLogTrace()
        {
            return new global::SqlKata.Query(""auth.v_UserRoleLogTrace"")
                .Select(""UserId"")
                .Select(""RoleId"")
                .Select(""LogId"")
                .Select(""TraceId"");
        }
        public static global::SqlKata.Query Insert_auth_UserRoleLogTrace(global::System.Guid userId, global::System.Guid roleId, int logId, global::System.Guid traceId)
        {
            var _columns = new global::System.Collections.Generic.List<string>();
            var _values = new global::System.Collections.Generic.List<object?>();
            _columns.Add(""UserId"");
            _values.Add(userId);
            _columns.Add(""RoleId"");
            _values.Add(roleId);
            _columns.Add(""LogId"");
            _values.Add(logId);
            _columns.Add(""TraceId"");
            _values.Add(traceId);
            return new global::SqlKata.Query(""auth.tbl_UserRoleLogTrace"")
                .AsInsert(_columns, _values);
        }
        public static global::SqlKata.Query Insert_auth_UserRoleLogTrace(global::System.Collections.Generic.IEnumerable<(global::System.Guid UserId, global::System.Guid RoleId, int LogId, global::System.Guid TraceId)> rows)
        {
            var _columns = new string[] {
                ""UserId"",
                ""RoleId"",
                ""LogId"",
                ""TraceId""
            };
            var _values = rows.Select(_row => new object?[] {
                _row.UserId,
                _row.RoleId,
                _row.LogId,
                _row.TraceId
            });
            return new global::SqlKata.Query(""auth.tbl_UserRoleLogTrace"")
                .AsInsert(_columns, _values);
        }
        public static global::SqlKata.Query Delete_auth_UserRoleLogTrace(global::System.Guid userId, global::System.Guid roleId, int logId, global::System.Guid traceId)
        {
            return new global::SqlKata.Query(""auth.tbl_UserRoleLogTrace"")
                .Where(""UserId"", userId)
                .Where(""RoleId"", roleId)
                .Where(""LogId"", logId)
                .Where(""TraceId"", traceId)
                .AsDelete();
        }
        public static global::SqlKata.Query Delete_auth_UserRoleLogTrace(global::System.Guid userId, global::System.Guid roleId, int logId)
        {
            return new global::SqlKata.Query(""auth.tbl_UserRoleLogTrace"")
                .Where(""UserId"", userId)
                .Where(""RoleId"", roleId)
                .Where(""LogId"", logId)
                .AsDelete();
        }
        public static global::SqlKata.Query Delete_auth_UserRoleLogTrace(global::System.Guid userId, global::System.Guid roleId)
        {
            return new global::SqlKata.Query(""auth.tbl_UserRoleLogTrace"")
                .Where(""UserId"", userId)
                .Where(""RoleId"", roleId)
                .AsDelete();
        }
        public static global::SqlKata.Query Delete_auth_UserRoleLogTrace(global::System.Guid userId)
        {
            return new global::SqlKata.Query(""auth.tbl_UserRoleLogTrace"")
                .Where(""UserId"", userId)
                .AsDelete();
        }
        public static global::SqlKata.Query Delete_auth_UserRoleLogTrace()
        {
            return new global::SqlKata.Query(""auth.tbl_UserRoleLogTrace"")
                .AsDelete();
        }
    }
}
", source);
        }
        public async Task TestWrite()
        {
            // Arrange
            var tSchema = AuthSchemaFixture.Create();
            var ast     = KayleeHelper.Parse(tSchema);
            // Act
            var entities = EntitiesWriter.Write(ast);
            // Assert
            await DebugUtils.WriteGeneratedFileToDisk("Entities.cs", entities).ConfigureAwait(false);

            Assert.Equal(@"#nullable enable

namespace Allvis.Kaylee.Generated.SqlKata
{
    public static class Entities
    {
        public static class auth
        {
            public class User
            {
                public global::System.Guid UserId { get; set; }
                public string? FirstName { get; set; }
                public string? LastName { get; set; }
                public string ContactEmail { get; set; } = string.Empty;
                public string NormalizedContactEmail { get; set; } = string.Empty;
                public byte[] Hash { get; set; } = global::System.Array.Empty<byte>();
                public byte[]? Picture { get; set; }
                public byte[] ETag { get; set; } = global::System.Array.Empty<byte>();
                public long RAM4 { get; set; }
                public decimal Price { get; set; }
            }
            public class UserTask
            {
                public global::System.Guid UserId { get; set; }
                public int TaskId { get; set; }
                public string Todo { get; set; } = string.Empty;
            }
            public class UserRole
            {
                public global::System.Guid UserId { get; set; }
                public global::System.Guid RoleId { get; set; }
                public int Flag { get; set; }
            }
            public class UserRoleLog
            {
                public global::System.Guid UserId { get; set; }
                public global::System.Guid RoleId { get; set; }
                public int LogId { get; set; }
                public string Content { get; set; } = string.Empty;
            }
            public class UserRoleLogTrace
            {
                public global::System.Guid UserId { get; set; }
                public global::System.Guid RoleId { get; set; }
                public int LogId { get; set; }
                public global::System.Guid TraceId { get; set; }
            }
        }
    }
}
", entities);
        }
Exemple #10
0
        public void TestParse()
        {
            // Arrange
            var tModel = ModelFixture.Create();
            // Act
            var ast = KayleeHelper.Parse(tModel);

            // Assert
            Assert.Collection(ast.Schemata,
                              s =>
            {
                Assert.Equal("auth", s.Name);
                Assert.Collection(s.Entities, e =>
                {
                    Assert.Equal("User", e.Name);
                    Assert.False(e.IsQuery);
                    Assert.Collection(e.Fields, f =>
                    {
                        Assert.Equal("UserId", f.Name);
                        Assert.Equal(FieldType.GUID, f.Type);
                        Assert.Equal("NEWID()", f.DefaultExpression);
                        Assert.False(f.Nullable);
                        Assert.False(f.Computed);
                    }, f =>
                    {
                        Assert.Equal("CreatedAt", f.Name);
                        Assert.Equal(FieldType.DATE, f.Type);
                        Assert.Equal("SYSDATETIMEOFFSET()", f.DefaultExpression);
                        Assert.False(f.Nullable);
                        Assert.False(f.Computed);
                    }, f =>
                    {
                        Assert.Equal("FirstName", f.Name);
                        Assert.Equal(FieldType.TEXT, f.Type);
                        Assert.Equal(100, f.Size.Size);
                        Assert.Equal(0, f.Size.Precision);
                        Assert.Null(f.DefaultExpression);
                        Assert.True(f.Nullable);
                        Assert.False(f.Computed);
                    }, f =>
                    {
                        Assert.Equal("LastName", f.Name);
                        Assert.Equal(FieldType.TEXT, f.Type);
                        Assert.Equal(100, f.Size.Size);
                        Assert.Equal(0, f.Size.Precision);
                        Assert.Null(f.DefaultExpression);
                        Assert.True(f.Nullable);
                        Assert.False(f.Computed);
                    }, f =>
                    {
                        Assert.Equal("ContactEmail", f.Name);
                        Assert.Equal(FieldType.TEXT, f.Type);
                        Assert.Equal(254, f.Size.Size);
                        Assert.Equal(0, f.Size.Precision);
                        Assert.Null(f.DefaultExpression);
                        Assert.True(f.Nullable);
                        Assert.False(f.Computed);
                    }, f =>
                    {
                        Assert.Equal("ContactPhone", f.Name);
                        Assert.Equal(FieldType.TEXT, f.Type);
                        Assert.Equal(50, f.Size.Size);
                        Assert.Equal(0, f.Size.Precision);
                        Assert.Null(f.DefaultExpression);
                        Assert.True(f.Nullable);
                        Assert.False(f.Computed);
                    }, f =>
                    {
                        Assert.Equal("Verified", f.Name);
                        Assert.Equal(FieldType.BIT, f.Type);
                        Assert.Equal("0", f.DefaultExpression);
                        Assert.False(f.Nullable);
                        Assert.False(f.Computed);
                    }, f =>
                    {
                        Assert.Equal("SuperUser", f.Name);
                        Assert.Equal(FieldType.BIT, f.Type);
                        Assert.Equal("0", f.DefaultExpression);
                        Assert.False(f.Nullable);
                        Assert.False(f.Computed);
                    }, f =>
                    {
                        Assert.Equal("NormalizedContactEmail", f.Name);
                        Assert.Equal(FieldType.TEXT, f.Type);
                        Assert.Equal(254, f.Size.Size);
                        Assert.Equal(0, f.Size.Precision);
                        Assert.Null(f.DefaultExpression);
                        Assert.False(f.Nullable);
                        Assert.True(f.Computed);
                    }, f =>
                    {
                        Assert.Equal("Hash", f.Name);
                        Assert.Equal(FieldType.BINARY, f.Type);
                        Assert.Equal(128, f.Size.Size);
                        Assert.Equal(0, f.Size.Precision);
                        Assert.Null(f.DefaultExpression);
                        Assert.False(f.Nullable);
                        Assert.False(f.Computed);
                    }, f =>
                    {
                        Assert.Equal("Picture", f.Name);
                        Assert.Equal(FieldType.VARBINARY, f.Type);
                        Assert.Equal(8192, f.Size.Size);
                        Assert.Equal(0, f.Size.Precision);
                        Assert.Null(f.DefaultExpression);
                        Assert.False(f.Nullable);
                        Assert.False(f.Computed);
                    }, f =>
                    {
                        Assert.Equal("CV", f.Name);
                        Assert.Equal(FieldType.VARBINARY, f.Type);
                        Assert.True(f.Size.IsMax);
                        Assert.Null(f.DefaultExpression);
                        Assert.False(f.Nullable);
                        Assert.False(f.Computed);
                    }, f =>
                    {
                        Assert.Equal("RAM4", f.Name);
                        Assert.Equal(FieldType.BIGINT, f.Type);
                        Assert.Null(f.DefaultExpression);
                        Assert.False(f.Nullable);
                        Assert.False(f.Computed);
                    }, f =>
                    {
                        Assert.Equal("Price", f.Name);
                        Assert.Equal(FieldType.DECIMAL, f.Type);
                        Assert.Equal(19, f.Size.Size);
                        Assert.Equal(4, f.Size.Precision);
                        Assert.Null(f.DefaultExpression);
                        Assert.False(f.Nullable);
                        Assert.False(f.Computed);
                    });
                    Assert.Collection(e.PrimaryKey, fr =>
                    {
                        Assert.Equal("UserId", fr.FieldName);
                        Assert.True(fr.IsResolved);
                        Assert.Equal(e.Fields.Single(f => f.Name == "UserId"), fr.ResolvedField);
                    });
                    Assert.Collection(e.Mutations, m =>
                    {
                        Assert.Equal("Name", m.Name);
                        Assert.Collection(m.FieldReferences, fr =>
                        {
                            Assert.Equal("FirstName", fr.FieldName);
                            Assert.True(fr.IsResolved);
                            Assert.Equal(e.Fields.Single(f => f.Name == "FirstName"), fr.ResolvedField);
                        }, fr =>
                        {
                            Assert.Equal("LastName", fr.FieldName);
                            Assert.True(fr.IsResolved);
                            Assert.Equal(e.Fields.Single(f => f.Name == "LastName"), fr.ResolvedField);
                        });
                    }, m =>
                    {
                        Assert.Equal("ContactInformation", m.Name);
                        Assert.Collection(m.FieldReferences, fr =>
                        {
                            Assert.Equal("ContactEmail", fr.FieldName);
                            Assert.True(fr.IsResolved);
                            Assert.Equal(e.Fields.Single(f => f.Name == "ContactEmail"), fr.ResolvedField);
                        }, fr =>
                        {
                            Assert.Equal("ContactPhone", fr.FieldName);
                            Assert.True(fr.IsResolved);
                            Assert.Equal(e.Fields.Single(f => f.Name == "ContactPhone"), fr.ResolvedField);
                        });
                    }, m =>
                    {
                        Assert.Equal("Verified", m.Name);
                        Assert.Collection(m.FieldReferences, fr =>
                        {
                            Assert.Equal("Verified", fr.FieldName);
                            Assert.True(fr.IsResolved);
                            Assert.Equal(e.Fields.Single(f => f.Name == "Verified"), fr.ResolvedField);
                        });
                    });
                });
            },
                              s =>
            {
                Assert.Equal("tenant", s.Name);
                Assert.Collection(s.Entities, e =>
                {
                    Assert.Equal("Tenant", e.Name);
                    Assert.False(e.IsQuery);
                    Assert.Collection(e.Children, e =>
                    {
                        Assert.Equal("Task", e.Name);
                        Assert.True(e.IsQuery);
                        Assert.Collection(e.PrimaryKey, fr =>
                        {
                            Assert.Equal("TaskId", fr.FieldName);
                            Assert.Equal(e.Fields.Single(f => f.Name == "TaskId"), fr.ResolvedField);
                        });
                    }, e =>
                    {
                        Assert.Equal("Procedure", e.Name);
                        Assert.False(e.IsQuery);
                        Assert.Collection(e.Children, e =>
                        {
                            Assert.Equal("Revision", e.Name);
                            Assert.False(e.IsQuery);
                            Assert.Collection(e.Children, e =>
                            {
                                Assert.Equal("Execution", e.Name);
                                Assert.False(e.IsQuery);
                                Assert.Collection(e.Children, e =>
                                {
                                    Assert.Equal("Comment", e.Name);
                                    Assert.False(e.IsQuery);
                                    Assert.Collection(e.Children, e =>
                                    {
                                        Assert.Equal("Delivery", e.Name);
                                        Assert.False(e.IsQuery);
                                        Assert.Collection(e.References, r =>
                                        {
                                            Assert.Collection(r.Source, fr =>
                                            {
                                                Assert.Equal("UserId", fr.FieldName);
                                                Assert.True(fr.IsResolved);
                                                Assert.Equal(e.Fields.Single(f => f.Name == "UserId"), fr.ResolvedField);
                                            });
                                            Assert.Collection(r.Target, fr =>
                                            {
                                                Assert.Equal("UserId", fr.FieldName);
                                                Assert.True(fr.IsResolved);
                                                Assert.Equal(s.Ast.Locate("auth", new[] { "User" }).Fields.Single(f => f.Name == "UserId"), fr.ResolvedField);
                                            });
                                        });
                                        Assert.Collection(e.References, r =>
                                        {
                                            Assert.Collection(r.Source, fr =>
                                            {
                                                Assert.Equal("UserId", fr.FieldName);
                                                Assert.True(fr.IsResolved);
                                                Assert.Equal(e.Fields.Single(f => f.Name == "UserId"), fr.ResolvedField);
                                            });
                                            Assert.Collection(r.Target, fr =>
                                            {
                                                Assert.Equal("UserId", fr.FieldName);
                                                Assert.True(fr.IsResolved);
                                                Assert.Equal(s.Ast.Locate("auth", new[] { "User" }).Fields.Single(f => f.Name == "UserId"), fr.ResolvedField);
                                            });
                                        });
                                    }, e =>
                                    {
                                        Assert.Equal("Reaction", e.Name);
                                        Assert.False(e.IsQuery);
                                        Assert.Collection(e.References, r =>
                                        {
                                            Assert.Collection(r.Source, fr =>
                                            {
                                                Assert.Equal("UserId", fr.FieldName);
                                                Assert.True(fr.IsResolved);
                                                Assert.Equal(e.Fields.Single(f => f.Name == "UserId"), fr.ResolvedField);
                                            });
                                            Assert.Collection(r.Target, fr =>
                                            {
                                                Assert.Equal("UserId", fr.FieldName);
                                                Assert.True(fr.IsResolved);
                                                Assert.Equal(s.Ast.Locate("auth", new[] { "User" }).Fields.Single(f => f.Name == "UserId"), fr.ResolvedField);
                                            });
                                        });
                                        Assert.Collection(e.UniqueKeys, k =>
                                        {
                                            Assert.Collection(k.FieldReferences, fr =>
                                            {
                                                Assert.Equal("CommentId", fr.FieldName);
                                                Assert.True(fr.IsResolved);
                                                Assert.Equal(e.Parent.Fields.Single(f => f.Name == "CommentId"), fr.ResolvedField);
                                            }, fr =>
                                            {
                                                Assert.Equal("Emoji", fr.FieldName);
                                                Assert.True(fr.IsResolved);
                                                Assert.Equal(e.Fields.Single(f => f.Name == "Emoji"), fr.ResolvedField);
                                            });
                                        });
                                    });
                                });
                            });
                        });
                    });
                });
            });
        }
        public async Task TestWrite()
        {
            // Arrange
            var tSchema = AuthSchemaFixture.Create();
            var ast     = KayleeHelper.Parse(tSchema);
            // Act
            var source = ExtensionsWriter.Write(ast);
            // Assert
            await DebugUtils.WriteGeneratedFileToDisk("Extensions.cs", source).ConfigureAwait(false);

            Assert.Equal(@"#nullable enable

using System.Linq;

namespace Allvis.Kaylee.Generated.SqlKata
{
    public static class Extensions
    {
        public static async global::System.Threading.Tasks.Task<bool> Exists_auth_User(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId)
        {
            var _rows = await _db.GetAsync<int>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Exists_auth_User(userId)).ConfigureAwait(false);
            return _rows.Any();
        }
        public static async global::System.Threading.Tasks.Task<bool> Exists_auth_User_UK_ContactEmail(this global::SqlKata.Execution.QueryFactory _db, string contactEmail)
        {
            var _rows = await _db.GetAsync<int>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Exists_auth_User_UK_ContactEmail(contactEmail)).ConfigureAwait(false);
            return _rows.Any();
        }
        public static async global::System.Threading.Tasks.Task<bool> Exists_auth_User_UK_NormalizedContactEmail(this global::SqlKata.Execution.QueryFactory _db, string normalizedContactEmail)
        {
            var _rows = await _db.GetAsync<int>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Exists_auth_User_UK_NormalizedContactEmail(normalizedContactEmail)).ConfigureAwait(false);
            return _rows.Any();
        }
        public static async global::System.Threading.Tasks.Task<bool> Exists_auth_User_UK_Hash_RAM4(this global::SqlKata.Execution.QueryFactory _db, byte[] hash, long rAM4)
        {
            var _rows = await _db.GetAsync<int>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Exists_auth_User_UK_Hash_RAM4(hash, rAM4)).ConfigureAwait(false);
            return _rows.Any();
        }
        public static global::System.Threading.Tasks.Task<int> Count_auth_User(this global::SqlKata.Execution.QueryFactory _db)
        {
            return _db.ExecuteScalarAsync<int>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Count_auth_User());
        }
        public static global::System.Threading.Tasks.Task<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.User> Get_auth_User(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId)
        {
            return _db.FirstAsync<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.User>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Get_auth_User(userId));
        }
        public static global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.User>> Get_auth_User(this global::SqlKata.Execution.QueryFactory _db)
        {
            return _db.GetAsync<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.User>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Get_auth_User());
        }
        public static global::System.Threading.Tasks.Task<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.User> Get_auth_User_UK_ContactEmail(this global::SqlKata.Execution.QueryFactory _db, string contactEmail)
        {
            return _db.FirstAsync<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.User>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Get_auth_User_UK_ContactEmail(contactEmail));
        }
        public static global::System.Threading.Tasks.Task<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.User> Get_auth_User_UK_NormalizedContactEmail(this global::SqlKata.Execution.QueryFactory _db, string normalizedContactEmail)
        {
            return _db.FirstAsync<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.User>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Get_auth_User_UK_NormalizedContactEmail(normalizedContactEmail));
        }
        public static global::System.Threading.Tasks.Task<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.User> Get_auth_User_UK_Hash_RAM4(this global::SqlKata.Execution.QueryFactory _db, byte[] hash, long rAM4)
        {
            return _db.FirstAsync<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.User>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Get_auth_User_UK_Hash_RAM4(hash, rAM4));
        }
        public static global::System.Threading.Tasks.Task<int> Insert_auth_User(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid? userId, string? firstName, string? lastName, string contactEmail, byte[] hash, byte[]? picture, long rAM4, decimal price)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Insert_auth_User(userId, firstName, lastName, contactEmail, hash, picture, rAM4, price));
        }
        public static global::System.Threading.Tasks.Task<int> Insert_auth_User(this global::SqlKata.Execution.QueryFactory _db, global::System.Collections.Generic.IEnumerable<(global::System.Guid UserId, string? FirstName, string? LastName, string ContactEmail, byte[] Hash, byte[]? Picture, long RAM4, decimal Price)> rows)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Insert_auth_User(rows));
        }
        public static global::System.Threading.Tasks.Task<int> Delete_auth_User(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Delete_auth_User(userId));
        }
        public static global::System.Threading.Tasks.Task<int> Delete_auth_User(this global::SqlKata.Execution.QueryFactory _db)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Delete_auth_User());
        }
        public static global::System.Threading.Tasks.Task<int> Delete_auth_User_UK_ContactEmail(this global::SqlKata.Execution.QueryFactory _db, string contactEmail)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Delete_auth_User_UK_ContactEmail(contactEmail));
        }
        public static global::System.Threading.Tasks.Task<int> Delete_auth_User_UK_NormalizedContactEmail(this global::SqlKata.Execution.QueryFactory _db, string normalizedContactEmail)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Delete_auth_User_UK_NormalizedContactEmail(normalizedContactEmail));
        }
        public static global::System.Threading.Tasks.Task<int> Delete_auth_User_UK_Hash_RAM4(this global::SqlKata.Execution.QueryFactory _db, byte[] hash, long rAM4)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Delete_auth_User_UK_Hash_RAM4(hash, rAM4));
        }
        public static global::System.Threading.Tasks.Task<int> Update_auth_User_FullName(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid k_UserId, string? firstName, string? lastName)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Update_auth_User_FullName(k_UserId, firstName, lastName));
        }
        public static global::System.Threading.Tasks.Task<int> Update_auth_User_FullName_UK_ContactEmail(this global::SqlKata.Execution.QueryFactory _db, string k_ContactEmail, string? firstName, string? lastName)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Update_auth_User_FullName_UK_ContactEmail(k_ContactEmail, firstName, lastName));
        }
        public static global::System.Threading.Tasks.Task<int> Update_auth_User_FullName_UK_NormalizedContactEmail(this global::SqlKata.Execution.QueryFactory _db, string k_NormalizedContactEmail, string? firstName, string? lastName)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Update_auth_User_FullName_UK_NormalizedContactEmail(k_NormalizedContactEmail, firstName, lastName));
        }
        public static global::System.Threading.Tasks.Task<int> Update_auth_User_FullName_UK_Hash_RAM4(this global::SqlKata.Execution.QueryFactory _db, byte[] k_Hash, long k_RAM4, string? firstName, string? lastName)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Update_auth_User_FullName_UK_Hash_RAM4(k_Hash, k_RAM4, firstName, lastName));
        }
        public static global::System.Threading.Tasks.Task<int> Update_auth_User_ContactInformation(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid k_UserId, string contactEmail)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Update_auth_User_ContactInformation(k_UserId, contactEmail));
        }
        public static global::System.Threading.Tasks.Task<int> Update_auth_User_ContactInformation_UK_ContactEmail(this global::SqlKata.Execution.QueryFactory _db, string k_ContactEmail, string contactEmail)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Update_auth_User_ContactInformation_UK_ContactEmail(k_ContactEmail, contactEmail));
        }
        public static global::System.Threading.Tasks.Task<int> Update_auth_User_ContactInformation_UK_NormalizedContactEmail(this global::SqlKata.Execution.QueryFactory _db, string k_NormalizedContactEmail, string contactEmail)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Update_auth_User_ContactInformation_UK_NormalizedContactEmail(k_NormalizedContactEmail, contactEmail));
        }
        public static global::System.Threading.Tasks.Task<int> Update_auth_User_ContactInformation_UK_Hash_RAM4(this global::SqlKata.Execution.QueryFactory _db, byte[] k_Hash, long k_RAM4, string contactEmail)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Update_auth_User_ContactInformation_UK_Hash_RAM4(k_Hash, k_RAM4, contactEmail));
        }
        public static async global::System.Threading.Tasks.Task<bool> Exists_auth_UserTask(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, int taskId)
        {
            var _rows = await _db.GetAsync<int>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Exists_auth_UserTask(userId, taskId)).ConfigureAwait(false);
            return _rows.Any();
        }
        public static global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<(global::System.Guid UserId, int Count)>> Count_auth_UserTask_GroupBy_UserId(this global::SqlKata.Execution.QueryFactory _db)
        {
            return _db.GetAsync<(global::System.Guid UserId, int Count)>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Count_auth_UserTask_GroupBy_UserId());
        }
        public static global::System.Threading.Tasks.Task<int> Count_auth_UserTask(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId)
        {
            return _db.ExecuteScalarAsync<int>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Count_auth_UserTask(userId));
        }
        public static global::System.Threading.Tasks.Task<int> Count_auth_UserTask(this global::SqlKata.Execution.QueryFactory _db)
        {
            return _db.ExecuteScalarAsync<int>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Count_auth_UserTask());
        }
        public static global::System.Threading.Tasks.Task<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserTask> Get_auth_UserTask(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, int taskId)
        {
            return _db.FirstAsync<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserTask>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Get_auth_UserTask(userId, taskId));
        }
        public static global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserTask>> Get_auth_UserTask(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId)
        {
            return _db.GetAsync<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserTask>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Get_auth_UserTask(userId));
        }
        public static global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserTask>> Get_auth_UserTask(this global::SqlKata.Execution.QueryFactory _db)
        {
            return _db.GetAsync<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserTask>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Get_auth_UserTask());
        }
        public static async global::System.Threading.Tasks.Task<bool> Exists_auth_UserRole(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, global::System.Guid roleId)
        {
            var _rows = await _db.GetAsync<int>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Exists_auth_UserRole(userId, roleId)).ConfigureAwait(false);
            return _rows.Any();
        }
        public static global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<(global::System.Guid UserId, int Count)>> Count_auth_UserRole_GroupBy_UserId(this global::SqlKata.Execution.QueryFactory _db)
        {
            return _db.GetAsync<(global::System.Guid UserId, int Count)>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Count_auth_UserRole_GroupBy_UserId());
        }
        public static global::System.Threading.Tasks.Task<int> Count_auth_UserRole(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId)
        {
            return _db.ExecuteScalarAsync<int>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Count_auth_UserRole(userId));
        }
        public static global::System.Threading.Tasks.Task<int> Count_auth_UserRole(this global::SqlKata.Execution.QueryFactory _db)
        {
            return _db.ExecuteScalarAsync<int>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Count_auth_UserRole());
        }
        public static global::System.Threading.Tasks.Task<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRole> Get_auth_UserRole(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, global::System.Guid roleId)
        {
            return _db.FirstAsync<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRole>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Get_auth_UserRole(userId, roleId));
        }
        public static global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRole>> Get_auth_UserRole(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId)
        {
            return _db.GetAsync<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRole>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Get_auth_UserRole(userId));
        }
        public static global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRole>> Get_auth_UserRole(this global::SqlKata.Execution.QueryFactory _db)
        {
            return _db.GetAsync<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRole>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Get_auth_UserRole());
        }
        public static global::System.Threading.Tasks.Task<int> Insert_auth_UserRole(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, global::System.Guid roleId, int? flag)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Insert_auth_UserRole(userId, roleId, flag));
        }
        public static global::System.Threading.Tasks.Task<int> Insert_auth_UserRole(this global::SqlKata.Execution.QueryFactory _db, global::System.Collections.Generic.IEnumerable<(global::System.Guid UserId, global::System.Guid RoleId, int Flag)> rows)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Insert_auth_UserRole(rows));
        }
        public static global::System.Threading.Tasks.Task<int> Delete_auth_UserRole(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, global::System.Guid roleId)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Delete_auth_UserRole(userId, roleId));
        }
        public static global::System.Threading.Tasks.Task<int> Delete_auth_UserRole(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Delete_auth_UserRole(userId));
        }
        public static global::System.Threading.Tasks.Task<int> Delete_auth_UserRole(this global::SqlKata.Execution.QueryFactory _db)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Delete_auth_UserRole());
        }
        public static global::System.Threading.Tasks.Task<int> Update_auth_UserRole_Flag(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid k_UserId, global::System.Guid k_RoleId, int flag)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Update_auth_UserRole_Flag(k_UserId, k_RoleId, flag));
        }
        public static async global::System.Threading.Tasks.Task<bool> Exists_auth_UserRoleLog(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, global::System.Guid roleId, int logId)
        {
            var _rows = await _db.GetAsync<int>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Exists_auth_UserRoleLog(userId, roleId, logId)).ConfigureAwait(false);
            return _rows.Any();
        }
        public static global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<(global::System.Guid UserId, global::System.Guid RoleId, int Count)>> Count_auth_UserRoleLog_GroupBy_UserId_RoleId(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId)
        {
            return _db.GetAsync<(global::System.Guid UserId, global::System.Guid RoleId, int Count)>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Count_auth_UserRoleLog_GroupBy_UserId_RoleId(userId));
        }
        public static global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<(global::System.Guid UserId, global::System.Guid RoleId, int Count)>> Count_auth_UserRoleLog_GroupBy_UserId_RoleId(this global::SqlKata.Execution.QueryFactory _db)
        {
            return _db.GetAsync<(global::System.Guid UserId, global::System.Guid RoleId, int Count)>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Count_auth_UserRoleLog_GroupBy_UserId_RoleId());
        }
        public static global::System.Threading.Tasks.Task<int> Count_auth_UserRoleLog(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, global::System.Guid roleId)
        {
            return _db.ExecuteScalarAsync<int>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Count_auth_UserRoleLog(userId, roleId));
        }
        public static global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<(global::System.Guid UserId, int Count)>> Count_auth_UserRoleLog_GroupBy_UserId(this global::SqlKata.Execution.QueryFactory _db)
        {
            return _db.GetAsync<(global::System.Guid UserId, int Count)>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Count_auth_UserRoleLog_GroupBy_UserId());
        }
        public static global::System.Threading.Tasks.Task<int> Count_auth_UserRoleLog(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId)
        {
            return _db.ExecuteScalarAsync<int>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Count_auth_UserRoleLog(userId));
        }
        public static global::System.Threading.Tasks.Task<int> Count_auth_UserRoleLog(this global::SqlKata.Execution.QueryFactory _db)
        {
            return _db.ExecuteScalarAsync<int>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Count_auth_UserRoleLog());
        }
        public static global::System.Threading.Tasks.Task<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRoleLog> Get_auth_UserRoleLog(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, global::System.Guid roleId, int logId)
        {
            return _db.FirstAsync<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRoleLog>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Get_auth_UserRoleLog(userId, roleId, logId));
        }
        public static global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRoleLog>> Get_auth_UserRoleLog(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, global::System.Guid roleId)
        {
            return _db.GetAsync<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRoleLog>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Get_auth_UserRoleLog(userId, roleId));
        }
        public static global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRoleLog>> Get_auth_UserRoleLog(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId)
        {
            return _db.GetAsync<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRoleLog>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Get_auth_UserRoleLog(userId));
        }
        public static global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRoleLog>> Get_auth_UserRoleLog(this global::SqlKata.Execution.QueryFactory _db)
        {
            return _db.GetAsync<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRoleLog>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Get_auth_UserRoleLog());
        }
        public static global::System.Threading.Tasks.Task<int> Insert_auth_UserRoleLog(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, global::System.Guid roleId, string content)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Insert_auth_UserRoleLog(userId, roleId, content));
        }
        public static global::System.Threading.Tasks.Task<int> Insert_auth_UserRoleLog(this global::SqlKata.Execution.QueryFactory _db, global::System.Collections.Generic.IEnumerable<(global::System.Guid UserId, global::System.Guid RoleId, string Content)> rows)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Insert_auth_UserRoleLog(rows));
        }
        public static global::System.Threading.Tasks.Task<int> Delete_auth_UserRoleLog(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, global::System.Guid roleId, int logId)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Delete_auth_UserRoleLog(userId, roleId, logId));
        }
        public static global::System.Threading.Tasks.Task<int> Delete_auth_UserRoleLog(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, global::System.Guid roleId)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Delete_auth_UserRoleLog(userId, roleId));
        }
        public static global::System.Threading.Tasks.Task<int> Delete_auth_UserRoleLog(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Delete_auth_UserRoleLog(userId));
        }
        public static global::System.Threading.Tasks.Task<int> Delete_auth_UserRoleLog(this global::SqlKata.Execution.QueryFactory _db)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Delete_auth_UserRoleLog());
        }
        public static async global::System.Threading.Tasks.Task<bool> Exists_auth_UserRoleLogTrace(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, global::System.Guid roleId, int logId, global::System.Guid traceId)
        {
            var _rows = await _db.GetAsync<int>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Exists_auth_UserRoleLogTrace(userId, roleId, logId, traceId)).ConfigureAwait(false);
            return _rows.Any();
        }
        public static global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<(global::System.Guid UserId, global::System.Guid RoleId, int LogId, int Count)>> Count_auth_UserRoleLogTrace_GroupBy_UserId_RoleId_LogId(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, global::System.Guid roleId)
        {
            return _db.GetAsync<(global::System.Guid UserId, global::System.Guid RoleId, int LogId, int Count)>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Count_auth_UserRoleLogTrace_GroupBy_UserId_RoleId_LogId(userId, roleId));
        }
        public static global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<(global::System.Guid UserId, global::System.Guid RoleId, int LogId, int Count)>> Count_auth_UserRoleLogTrace_GroupBy_UserId_RoleId_LogId(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId)
        {
            return _db.GetAsync<(global::System.Guid UserId, global::System.Guid RoleId, int LogId, int Count)>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Count_auth_UserRoleLogTrace_GroupBy_UserId_RoleId_LogId(userId));
        }
        public static global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<(global::System.Guid UserId, global::System.Guid RoleId, int LogId, int Count)>> Count_auth_UserRoleLogTrace_GroupBy_UserId_RoleId_LogId(this global::SqlKata.Execution.QueryFactory _db)
        {
            return _db.GetAsync<(global::System.Guid UserId, global::System.Guid RoleId, int LogId, int Count)>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Count_auth_UserRoleLogTrace_GroupBy_UserId_RoleId_LogId());
        }
        public static global::System.Threading.Tasks.Task<int> Count_auth_UserRoleLogTrace(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, global::System.Guid roleId, int logId)
        {
            return _db.ExecuteScalarAsync<int>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Count_auth_UserRoleLogTrace(userId, roleId, logId));
        }
        public static global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<(global::System.Guid UserId, global::System.Guid RoleId, int Count)>> Count_auth_UserRoleLogTrace_GroupBy_UserId_RoleId(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId)
        {
            return _db.GetAsync<(global::System.Guid UserId, global::System.Guid RoleId, int Count)>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Count_auth_UserRoleLogTrace_GroupBy_UserId_RoleId(userId));
        }
        public static global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<(global::System.Guid UserId, global::System.Guid RoleId, int Count)>> Count_auth_UserRoleLogTrace_GroupBy_UserId_RoleId(this global::SqlKata.Execution.QueryFactory _db)
        {
            return _db.GetAsync<(global::System.Guid UserId, global::System.Guid RoleId, int Count)>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Count_auth_UserRoleLogTrace_GroupBy_UserId_RoleId());
        }
        public static global::System.Threading.Tasks.Task<int> Count_auth_UserRoleLogTrace(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, global::System.Guid roleId)
        {
            return _db.ExecuteScalarAsync<int>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Count_auth_UserRoleLogTrace(userId, roleId));
        }
        public static global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<(global::System.Guid UserId, int Count)>> Count_auth_UserRoleLogTrace_GroupBy_UserId(this global::SqlKata.Execution.QueryFactory _db)
        {
            return _db.GetAsync<(global::System.Guid UserId, int Count)>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Count_auth_UserRoleLogTrace_GroupBy_UserId());
        }
        public static global::System.Threading.Tasks.Task<int> Count_auth_UserRoleLogTrace(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId)
        {
            return _db.ExecuteScalarAsync<int>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Count_auth_UserRoleLogTrace(userId));
        }
        public static global::System.Threading.Tasks.Task<int> Count_auth_UserRoleLogTrace(this global::SqlKata.Execution.QueryFactory _db)
        {
            return _db.ExecuteScalarAsync<int>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Count_auth_UserRoleLogTrace());
        }
        public static global::System.Threading.Tasks.Task<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRoleLogTrace> Get_auth_UserRoleLogTrace(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, global::System.Guid roleId, int logId, global::System.Guid traceId)
        {
            return _db.FirstAsync<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRoleLogTrace>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Get_auth_UserRoleLogTrace(userId, roleId, logId, traceId));
        }
        public static global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRoleLogTrace>> Get_auth_UserRoleLogTrace(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, global::System.Guid roleId, int logId)
        {
            return _db.GetAsync<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRoleLogTrace>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Get_auth_UserRoleLogTrace(userId, roleId, logId));
        }
        public static global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRoleLogTrace>> Get_auth_UserRoleLogTrace(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, global::System.Guid roleId)
        {
            return _db.GetAsync<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRoleLogTrace>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Get_auth_UserRoleLogTrace(userId, roleId));
        }
        public static global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRoleLogTrace>> Get_auth_UserRoleLogTrace(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId)
        {
            return _db.GetAsync<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRoleLogTrace>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Get_auth_UserRoleLogTrace(userId));
        }
        public static global::System.Threading.Tasks.Task<global::System.Collections.Generic.IEnumerable<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRoleLogTrace>> Get_auth_UserRoleLogTrace(this global::SqlKata.Execution.QueryFactory _db)
        {
            return _db.GetAsync<global::Allvis.Kaylee.Generated.SqlKata.Entities.auth.UserRoleLogTrace>(global::Allvis.Kaylee.Generated.SqlKata.Queries.Get_auth_UserRoleLogTrace());
        }
        public static global::System.Threading.Tasks.Task<int> Insert_auth_UserRoleLogTrace(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, global::System.Guid roleId, int logId, global::System.Guid traceId)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Insert_auth_UserRoleLogTrace(userId, roleId, logId, traceId));
        }
        public static global::System.Threading.Tasks.Task<int> Insert_auth_UserRoleLogTrace(this global::SqlKata.Execution.QueryFactory _db, global::System.Collections.Generic.IEnumerable<(global::System.Guid UserId, global::System.Guid RoleId, int LogId, global::System.Guid TraceId)> rows)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Insert_auth_UserRoleLogTrace(rows));
        }
        public static global::System.Threading.Tasks.Task<int> Delete_auth_UserRoleLogTrace(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, global::System.Guid roleId, int logId, global::System.Guid traceId)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Delete_auth_UserRoleLogTrace(userId, roleId, logId, traceId));
        }
        public static global::System.Threading.Tasks.Task<int> Delete_auth_UserRoleLogTrace(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, global::System.Guid roleId, int logId)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Delete_auth_UserRoleLogTrace(userId, roleId, logId));
        }
        public static global::System.Threading.Tasks.Task<int> Delete_auth_UserRoleLogTrace(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId, global::System.Guid roleId)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Delete_auth_UserRoleLogTrace(userId, roleId));
        }
        public static global::System.Threading.Tasks.Task<int> Delete_auth_UserRoleLogTrace(this global::SqlKata.Execution.QueryFactory _db, global::System.Guid userId)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Delete_auth_UserRoleLogTrace(userId));
        }
        public static global::System.Threading.Tasks.Task<int> Delete_auth_UserRoleLogTrace(this global::SqlKata.Execution.QueryFactory _db)
        {
            return _db.ExecuteAsync(global::Allvis.Kaylee.Generated.SqlKata.Queries.Delete_auth_UserRoleLogTrace());
        }
    }
}
", source);
        }