示例#1
0
        public void TestSelect_19()
        {
            _clause = new SelectClause(new SqlServerDialect(), new TestEntityResolver(), new TestEntityAliasRegister());
            _clause.Select <Sample>(t => new object[] { t.Email, t.IntValue });
            var result = _clause.ToSql();

            Assert.Equal("Select [as_Sample].[t_Email],[as_Sample].[t_IntValue]", result);
        }
示例#2
0
        public void TestSelect_26()
        {
            _clause = new SelectClause(new SqlServerBuilder(), new SqlServerDialect(), new EntityResolver(new TestEntityMatedata()), new TestEntityAliasRegister());
            _clause.Select <Sample>(t => new object[] { t.Email, t.DecimalValue }, true);
            var result = _clause.ToSql();

            Assert.Equal("Select [as_Sample].[Sample_Email] As [Email],[as_Sample].[DecimalValue]", result);
        }
        /// <summary>
        /// 添加Select子句
        /// </summary>
        protected virtual void AppendSelect(StringBuilder result)
        {
            var sql = SelectClause.ToSql();

            if (string.IsNullOrWhiteSpace(sql))
            {
                throw new InvalidOperationException("必须设置Select子句");
            }
            AppendSql(result, sql);
        }
示例#4
0
        public void TestSelect_24()
        {
            _clause = new SelectClause(new SqlServerBuilder(), new SqlServerDialect(), new EntityResolver(new TestEntityMatedata()), new TestEntityAliasRegister());
            _clause.Select <Sample>(t => new Dictionary <object, string> {
                { t.Email, "e" }, { t.Url, "u" }
            });
            var result = _clause.ToSql();

            Assert.Equal("Select [as_Sample].[Sample_Email] As [e],[as_Sample].[Sample_Url] As [u]", result);
        }
示例#5
0
 /// <summary>
 /// 获取Sql语句
 /// </summary>
 private string GetSql()
 {
     return(_clause.ToSql());
 }
示例#6
0
 /// <summary>
 /// 获取Sql语句
 /// </summary>
 private string GetSql() => _clause.ToSql();
 /// <summary>
 /// 获取Select语句
 /// </summary>
 /// <returns></returns>
 public virtual string GetSelect()
 {
     return(SelectClause.ToSql());
 }