Example #1
0
        public void TestPage_1()
        {
            var pager = new QueryParameter();

            _builder.From("a").Page(pager);
            AssertHelper.Throws <ArgumentException>(() => _builder.ToSql(), LibraryResource.OrderIsEmptyForPage);
        }
Example #2
0
        public void Test_36()
        {
            //结果
            var result = new String();

            result.AppendLine("Select * ");
            result.AppendLine("From [Sample] As [k] ");
            result.Append("Where [k].[Email]=@_p_0 And [k].[StringValue] Like @_p_1");

            //执行
            _builder.From <Sample>("k").Where <Sample>(t => t.Email == "a" && t.StringValue.Contains("b"));

            //验证
            Assert.Equal(result.ToString(), _builder.ToSql());
            Assert.Equal(2, _builder.GetParams().Count);
            Assert.Equal("a", _builder.GetParams()["@_p_0"]);
            Assert.Equal("%b%", _builder.GetParams()["@_p_1"]);
        }
Example #3
0
        public void TestFrom_1()
        {
            //结果
            var result = new String();

            result.AppendLine("Select * ");
            result.Append("From [a]");

            //执行
            _builder.From("a");

            //验证
            Assert.Equal(result.ToString(), _builder.ToSql());
        }
Example #4
0
 public void TestWhere_18()
 {
     _builder.From("Test", "").From <Sample>("Test2").From <Sample>("").Where("Name", "a");
     Assert.Equal($"Select * {Common.Line}From [Sample] As [t] {Common.Line}Where [t].[Name]=@_p__0", _builder.ToSql());
     Assert.Single(_builder.GetParams());
     Assert.Equal("a", _builder.GetParams()["@_p__0"]);
 }