示例#1
0
        public void To_String()
        {
            IAlias person = sql.Alias("dbo.person");
            IFrom  from   = sql.From(person);

            Assert.Equal("FROM dbo.person", from.ToString());
        }
示例#2
0
        public void To_String_Subquery()
        {
            IAlias person = sql.Alias("person");
            IFrom  from   = sql.From(sql.RawQuery("Subquery"), person);

            Assert.Equal("FROM (Subquery) AS person", from.ToString());
        }
示例#3
0
        // twin method
        internal static FromChainer From(this IFrom prev, IOpenView table, DbNode node)
        {
            var cfrom = new FromChainer((Chainer)prev, table);

            cfrom.SetNode(node);
            return(cfrom);
        }
示例#4
0
        public void To_String_Typed_Alias()
        {
            IAlias <Person> person = sql.Alias <Person>();
            IFrom           from   = sql.From(person);

            Assert.Equal("FROM Person AS person", from.ToString());
        }
示例#5
0
        public void To_String_Options()
        {
            IAlias person = sql.Alias("person");
            IFrom  from   = sql.From(person).Options(sql.Raw("WITH (NO LOCK)"));

            Assert.Equal("FROM person WITH (NO LOCK)", from.ToString());
        }
示例#6
0
        public void WriteFragment_Parentheses()
        {
            IFrom  from   = sql.From("person");
            string result = ToStringBuilder.Build(b => b.WriteFragment(from, true));

            Assert.Equal("(FROM person)", result);
        }
示例#7
0
        public void To_String_Typed_Alias_With_Alias_Name()
        {
            IAlias <Person2> person = sql.Alias <Person2>("per");
            IFrom            from   = sql.From(person);

            Assert.Equal("FROM Person2 AS per", from.ToString());
        }
示例#8
0
        public void AliasOrTableName_Property_Alias_Name()
        {
            IAlias person = sql.Alias("dbo.person", "per");
            IFrom  from   = sql.From(person);

            Assert.Equal("per", from.AliasOrTableName);
        }
示例#9
0
        public void WriteValue_Fragment()
        {
            IFrom  from   = sql.From("person");
            string result = ToStringBuilder.Build(b => b.WriteValue(from));

            Assert.Equal("FROM person", result);
        }
示例#10
0
        public void To_String_With_Alias_Name()
        {
            IAlias person = sql.Alias("dbo.person", "per");
            IFrom  from   = sql.From(person);

            Assert.Equal("FROM dbo.person AS per", from.ToString());
        }
示例#11
0
        public void From_Subquery_String()
        {
            IFrom from = sql.From(sql.RawQuery("Subquery"), "sub");

            QueryResult result = engine.Compile(from);

            Assert.Equal("FROM (Subquery) AS \"sub\"", result.Sql);
        }
示例#12
0
        public void IfNotNull_Null_Value()
        {
            IFrom  from   = null;
            string result = ToStringBuilder.Build(b => b
                                                  .IfNotNull(from, (x) => b.WriteFragment(x)));

            Assert.Equal("", result);
        }
示例#13
0
        public void IfNotNull_Delegate_Without_Value_Null_Value()
        {
            IFrom  from   = null;
            string result = ToStringBuilder.Build(b => b
                                                  .IfNotNull(from, () => b.WriteFragment(from)));

            Assert.Equal("", result);
        }
示例#14
0
        public void IfNot_True()
        {
            IFrom  from   = sql.From("person");
            string result = ToStringBuilder.Build(b => b
                                                  .IfNot(from == null, () => b.WriteFragment(from)));

            Assert.Equal("FROM person", result);
        }
示例#15
0
        public void IfNot_False()
        {
            IFrom  from   = null;
            string result = ToStringBuilder.Build(b => b
                                                  .IfNot(from == null, () => b.WriteFragment(from)));

            Assert.Equal("", result);
        }
示例#16
0
        public void From_String()
        {
            IFrom from = sql.From("dbo.person");

            QueryResult result = engine.Compile(from);

            Assert.Equal("FROM \"dbo\".\"person\"", result.Sql);
        }
示例#17
0
        public void IfNotNull()
        {
            IFrom  from   = sql.From("person");
            string result = ToStringBuilder.Build(b => b
                                                  .IfNotNull(from, (x) => b.WriteFragment(x)));

            Assert.Equal("FROM person", result);
        }
示例#18
0
        public void From_String_With_Alias_Name()
        {
            IFrom from = sql.From("dbo.person", "per");

            QueryResult result = engine.Compile(from);

            Assert.Equal("FROM \"dbo\".\"person\" AS \"per\"", result.Sql);
        }
示例#19
0
        public void IfNotNull_Delegate_Without_Value()
        {
            IFrom  from   = sql.From("person");
            string result = ToStringBuilder.Build(b => b
                                                  .IfNotNull(from, () => b.WriteFragment(from)));

            Assert.Equal("FROM person", result);
        }
示例#20
0
        public void From_Typed_Alias()
        {
            IAlias <Person> person = sql.Alias <Person>();
            IFrom           from   = sql.From(person);

            QueryResult result = engine.Compile(from);

            Assert.Equal("FROM \"Person\" AS \"person\"", result.Sql);
        }
示例#21
0
        public void From_Subquery_Expression()
        {
            Person person = null;
            IFrom  from   = sql.From(sql.RawQuery("Subquery"), () => person);

            QueryResult result = engine.Compile(from);

            Assert.Equal("FROM (Subquery) AS \"person\"", result.Sql);
        }
示例#22
0
        public void From_Expression()
        {
            Person2 person = null;
            IFrom   from   = sql.From(() => person);

            QueryResult result = engine.Compile(from);

            Assert.Equal("FROM \"dbo\".\"Person\" AS \"person\"", result.Sql);
        }
示例#23
0
        public void From_Typed_Alias_With_Alias_Name()
        {
            IAlias <Person2> person = sql.Alias <Person2>("per");
            IFrom            from   = sql.From(person);

            QueryResult result = engine.Compile(from);

            Assert.Equal("FROM \"dbo\".\"Person\" AS \"per\"", result.Sql);
        }
示例#24
0
        public void From_Alias()
        {
            IAlias person = sql.Alias("dbo.person");
            IFrom  from   = sql.From(person);

            QueryResult result = engine.Compile(from);

            Assert.Equal("FROM \"dbo\".\"person\"", result.Sql);
        }
示例#25
0
        public void Options()
        {
            Person person = null;
            IFrom  from   = sql.From(() => person).Options(sql.Raw("WITH (NO LOCK)"));

            QueryResult result = engine.Compile(from);

            Assert.Equal("FROM \"Person\" AS \"person\" WITH (NO LOCK)", result.Sql);
        }
示例#26
0
        public void From_Alias_With_Alias_Name()
        {
            IAlias person = sql.Alias("person", "per");
            IFrom  from   = sql.From(person);

            QueryResult result = engine.Compile(from);

            Assert.Equal("FROM \"person\" AS \"per\"", result.Sql);
        }
示例#27
0
        public void From_Subquery_Alias()
        {
            IAlias person = sql.Alias("person");
            IFrom  from   = sql.From(sql.RawQuery("Subquery"), person);

            QueryResult result = engine.Compile(from);

            Assert.Equal("FROM (Subquery) AS \"person\"", result.Sql);
        }
示例#28
0
 public InnerJoin(IFrom thisEntity, Attribute thisJoinAttr, IFrom joinedEntity, Attribute joinedAttr,
                  string alias = null)
 {
     _thisEntity   = thisEntity;
     _thisJoinAttr = thisJoinAttr;
     _joinedEntity = joinedEntity;
     _joinedAttr   = joinedAttr;
     _alias        = alias;
 }
示例#29
0
        public void From_Cte_String()
        {
            IAlias person = sql.Alias("person");
            ICte   cte    = sql.Cte("cte").As(sql.Query.Select(person.All).From(person));
            IFrom  from   = sql.From(cte, "personCte");

            QueryResult result = engine.Compile(from);

            Assert.Equal("FROM \"cte\" AS \"personCte\"", result.Sql);
        }
示例#30
0
 public SelectFrom <TSelectedColumns> From(IFrom from)
 {
     if (this.FromNode != null)
     {
         throw new ApplicationException();
     }
     QueryNodeHelper.SwitchParent(from, this);
     this.FromNode = from;
     return(this);
 }
示例#31
0
 public TSelect(StringBuilder sb,IFrom tf,IWhere tw)
 {
     this.sql = sb;
     this.tfrom = tf;
     this.twhere = tw;
 }
示例#32
0
 public TSelect()
 {
     sql = new StringBuilder();
     twhere = new TWhere(sql);
     tfrom = new TFrom(sql);
 }
示例#33
0
 public TUpdate()
 {
     this.sql = new StringBuilder();
     tfrom = new TFrom(sql);
     this.twhere = new TWhere(sql);
 }
示例#34
0
 public TUpdate(StringBuilder sb)
 {
     this.sql = sb;
     tfrom = new TFrom(sql);
     this.twhere = new TWhere(sql);
 }
示例#35
0
 public TDelete()
 {
     sql = new StringBuilder();
     tfrom = new TFrom(sql);
 }
示例#36
0
 public TDelete(StringBuilder sb)
 {
     this.sql = sb;
     tfrom = new TFrom(sql);
 }