예제 #1
0
        public async Task SelectPageSqlTest()
        {
            using Sqless sqless = new Sqless(Global.AllowUnspecifiedConfig);
            SqlessSelectSqlBuilder producer = new SqlessSelectSqlBuilder(sqless, SelectPageTestRequest);
            var sqlStr = await producer.GetSqlStrTest();

            Assert.AreEqual(sqlStr.Replace("  ", " ").Trim(), "SELECT [Uid],[Name] FROM [User] ORDER BY [Uid] Asc OFFSET 2 ROWS FETCH NEXT 2 ROWS ONLY");
        }
예제 #2
0
        public async Task SelectFieldSqlTest()
        {
            using Sqless sqless = new Sqless(Global.AllowUnspecifiedConfig);
            SqlessSelectSqlBuilder producer = new SqlessSelectSqlBuilder(sqless, SelectFieldTestRequest);
            var sqlStr = await producer.GetSqlStrTest();

            Assert.AreEqual(sqlStr.Replace("  ", " ").Trim(), "SELECT TOP 20 [Uid],[Name] FROM [User]");
        }
예제 #3
0
        public async Task SelectNullSqlTest()
        {
            using Sqless sqless = new Sqless(Global.AllowUnspecifiedConfig);
            SqlessSelectSqlBuilder producer = new SqlessSelectSqlBuilder(sqless, SelectNullTestRequest);
            var sqlStr = await producer.GetSqlStrTest();

            Assert.AreEqual(sqlStr.Replace("  ", " ").Trim(), "SELECT [Name] FROM [User] WHERE [Phone] IS NULL");
        }
예제 #4
0
        public async Task SelectSqlTest()
        {
            using Sqless sqless = new Sqless(SelectConfig);
            SqlessSelectSqlBuilder producer = new SqlessSelectSqlBuilder(sqless, SelectRequest);
            var sqlStr = await producer.GetSqlStrTest();

            Assert.AreEqual(sqlStr.Replace("  ", " ").Trim(), "SELECT TOP 2 [Name],[Price] FROM [Product]");
        }
예제 #5
0
        public async Task RightJoinSqlTest()
        {
            var request = JoinRequest;

            request.Joins[0].SqlessJoinType = SqlessJoinType.RightJoin;

            using Sqless sqless = new Sqless(Global.AllowUnspecifiedConfig);
            SqlessSelectSqlBuilder producer = new SqlessSelectSqlBuilder(sqless, request);
            var sqlStr = await producer.GetSqlStrTest();

            Assert.AreEqual(sqlStr.Replace("  ", " ").Trim(), "SELECT [User].[Name],[User].[Uid],[Order].[Time] FROM [User] RIGHT JOIN [Order] ON [User].[Uid] = [Order].[Uid] WHERE [User].[Phone] IS NOT NULL");
        }
예제 #6
0
        public async Task AccessSelectSqlTest()
        {
            var request = new SqlessSelectRequest()
            {
                Table    = Tables.User,
                PageSize = 2,
                Fields   = new List <Query.SqlessField>
                {
                    new Query.SqlessField()
                    {
                        Field = "Name"
                    }
                }
            };

            using Sqless sqless = new Sqless(Global.GetOwnerAccessConfig("1"));
            SqlessSelectSqlBuilder producer = new SqlessSelectSqlBuilder(sqless, request);
            var sqlStr = await producer.GetSqlStrTest();

            Assert.AreEqual(sqlStr.Replace("  ", " ").Trim(), "SELECT TOP 2 [Name] FROM [User] WHERE [User].[Uid] = '1'");
        }