Exemplo n.º 1
0
        public void Test_On_13()
        {
            //结果
            var result = new Str();

            result.Append("Join [Sample] As [t] ");
            result.AppendLine("On [a].[id]=@_p_0 ");
            result.Append("Join [Sample2] As [t2] ");
            result.Append("On [t].[ShortValue]>[t2].[IntValue] And [t].[IntValue]=@_p_1");

            //操作
            _clause.Join <Sample>("t");
            _clause.On("a.id", "b");
            _clause.Join <Sample2>("t2");
            _clause.On <Sample, Sample2>((l, r) => l.ShortValue > r.IntValue && l.IntValue == 1);

            //验证
            Assert.Equal(result.ToString(), GetSql());
            Assert.Equal("b", _parameterManager.GetParams()["@_p_0"]);
            Assert.Equal(1, _parameterManager.GetParams()["@_p_1"]);
        }
Exemplo n.º 2
0
        public void TestBetween_1()
        {
            //结果
            var result = new String();

            result.Append("Where [a].[B]>=@_p_0 And [a].[B]<=@_p_1");

            //执行
            _clause.Between("a.B", 1, 2, Boundary.Both);

            //验证
            Assert.Equal(1, _parameterManager.GetParams()["@_p_0"]);
            Assert.Equal(2, _parameterManager.GetParams()["@_p_1"]);
            Assert.Equal(result.ToString(), GetSql());
        }
        public void TestResolve_2()
        {
            Expression <Func <Sample, bool> > expression = t => t.Email == "a";

            Assert.Equal("[Email]=@_p_0", _resolver.Resolve(expression).GetCondition());
            Assert.Equal("a", _parameterManager.GetParams()["@_p_0"]);
        }