Пример #1
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);
        }
Пример #2
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 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);
        }
Пример #4
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 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);
        }