Exemple #1
0
        public void Test_1()
        {
            var item = new NameItem("a");

            Assert.Equal("a", item.Name);
            Assert.Empty(item.Prefix);
            Assert.Equal("[b].[a]", item.ToSql(new SqlServerDialect(), "b"));
            Assert.Equal("[test].[b].[a]", item.ToSql(new SqlServerDialect(), "b", _database));
        }
Exemple #2
0
        public void Test_14()
        {
            var item = new NameItem("a.b.c");

            Assert.Equal("c", item.Name);
            Assert.Equal("b", item.Prefix);
            Assert.Equal("a", item.DatabaseName);
            Assert.Equal("[a].[b].[c]", item.ToSql(new SqlServerDialect(), "f", _database));
        }
        /// <summary>
        /// 获取Sql
        /// </summary>
        /// <param name="dialect">Sql方言</param>
        /// <param name="register">实体别名注册器</param>
        public string ToSql(IDialect dialect, IEntityAliasRegister register)
        {
            if (Raw)
            {
                return(Order);
            }
            var name = new NameItem(Order);

            return($"{name.ToSql( dialect, GetPrefix( register ) )} {( Desc ? "Desc" : null )}".TrimEnd());
        }