Beispiel #1
0
        public QueryResult Raw_Format()
        {
            IAlias    person = sql.Alias("person");
            IRawQuery query  = sql.RawQuery("SELECT {0} FROM {1} WHERE {2} = {3}", person.All, person, person["Id"], 1);

            return(engine.Compile(query));
        }
Beispiel #2
0
        public void To_String_Before()
        {
            IRawQuery rawQuery = sql.RawQuery("SELECT * FROM person")
                                 .Before(sql.Raw("BEFORE VALUE"))
                                 .Offset(10).Fetch(20);

            Assert.Equal("BEFORE VALUE SELECT * FROM person OFFSET 10 FETCH 20", rawQuery.ToString());
        }
Beispiel #3
0
        public void To_String_After()
        {
            IRawQuery rawQuery = sql.RawQuery("SELECT * FROM person")
                                 .Offset(10).Fetch(20)
                                 .After(sql.Raw("AFTER VALUE"));

            Assert.Equal("SELECT * FROM person OFFSET 10 FETCH 20 AFTER VALUE", rawQuery.ToString());
        }
Beispiel #4
0
        public void SubQuery()
        {
            IRawQuery rawQuery = sql.RawQuery("SELECT * FROM person");

            QueryResult result = engine.Compile(sql.Raw("{0}", rawQuery));

            Assert.Equal("(SELECT * FROM person)", result.Sql);
            Assert.Equal(new Dictionary <string, object>(), result.Parameters);
        }
Beispiel #5
0
        public void Before()
        {
            IRawQuery rawQuery = sql.RawQuery("SELECT * FROM person").Before(sql.Raw("BEFORE VALUE"));

            QueryResult result = engine.Compile(rawQuery);

            Assert.Equal("BEFORE VALUE SELECT * FROM person", result.Sql);
            Assert.Equal(new Dictionary <string, object>(), result.Parameters);
        }
Beispiel #6
0
        public void After()
        {
            IRawQuery rawQuery = sql.RawQuery("SELECT * FROM person").After(sql.Raw("AFTER VALUE"));

            QueryResult result = engine.Compile(rawQuery);

            Assert.Equal("SELECT * FROM person AFTER VALUE", result.Sql);
            Assert.Equal(new Dictionary <string, object>(), result.Parameters);
        }
        protected virtual IEnumerable <TOut> OnRawQueryAs <TContract, TOut>(IRawQuery query)
            where TContract : class
            where TOut : class
        {
            Ensure.That(query, "query").IsNotNull();

            var structureSchema = OnUpsertStructureSchema <TContract>();

            return(Db.Serializer.DeserializeMany <TOut>(DbClient.ReadJson(structureSchema, query.QueryString, query.Parameters)));
        }
        public virtual IEnumerable <string> RawQueryAsJson <T>(IRawQuery query) where T : class
        {
            return(Try(() =>
            {
                Ensure.That(query, "query").IsNotNull();

                OnUpsertStructureSchema <T>();

                return DbClient.YieldJson(query.QueryString, query.Parameters);
            }));
        }
Beispiel #9
0
        public void Offset()
        {
            IRawQuery rawQuery = sql.RawQuery("SELECT * FROM person").Offset(10);

            QueryResult result = engine.Compile(rawQuery);

            Assert.Equal("SELECT * FROM person OFFSET @p0 ROWS", result.Sql);
            Assert.Equal(new Dictionary <string, object>
            {
                ["@p0"] = 10
            }, result.Parameters);
        }
Beispiel #10
0
        public void Offset_Value()
        {
            IRawQuery rawQuery = sql.RawQuery("SELECT * FROM person").Offset(sql.Offset(10).Fetch(20));

            QueryResult result = engine.Compile(rawQuery);

            Assert.Equal("SELECT * FROM person OFFSET @p0 ROWS FETCH NEXT @p1 ROWS ONLY", result.Sql);
            Assert.Equal(new Dictionary <string, object>()
            {
                ["@p0"] = 10, ["@p1"] = 20
            }, result.Parameters);
        }
Beispiel #11
0
        public void Raw_Format()
        {
            IAlias    person   = sql.Alias("person");
            IRawQuery rawQuery = sql.RawQuery("SELECT {0}, {1} FROM {2}", person["Name"], "Some text", person);

            QueryResult result = engine.Compile(rawQuery);

            Assert.Equal("SELECT \"person\".\"Name\", @p0 FROM \"person\"", result.Sql);
            Assert.Equal(new Dictionary <string, object>
            {
                ["@p0"] = "Some text"
            }, result.Parameters);
        }
 public virtual void Visit(IRawQuery query)
 {
 }
 public virtual void Visit(IRawQuery query) => Write("raw");
		public void Visit(IRawQuery filter) => Write("script");
Beispiel #15
0
 public void Visit(IRawQuery filter) => Write("script");
 public virtual IEnumerable <T> RawQuery <T>(IRawQuery query) where T : class
 {
     return(Try(() => OnRawQueryAs <T, T>(query)));
 }
Beispiel #17
0
        public void To_String_Offset()
        {
            IRawQuery rawQuery = sql.RawQuery("SELECT * FROM person").Offset(10).Fetch(20);

            Assert.Equal("SELECT * FROM person OFFSET 10 FETCH 20", rawQuery.ToString());
        }
Beispiel #18
0
        public void To_String()
        {
            IRawQuery rawQuery = sql.RawQuery("SELECT * FROM person");

            Assert.Equal("SELECT * FROM person", rawQuery.ToString());
        }
 public virtual IEnumerable <TOut> RawQueryAs <TContract, TOut>(IRawQuery query) where TContract : class where TOut : class
 {
     return(Try(() => OnRawQueryAs <TContract, TOut>(query)));
 }
		public virtual void Visit(IRawQuery query) => Write("raw");
		public virtual void Visit(IRawQuery query) { }
 public void Visit(IRawQuery filter) => Write("raw");
Beispiel #23
0
 /// <summary>
 /// Sets the query of the CTE.
 /// </summary>
 /// <param name="query">The query.</param>
 /// <returns>The CTE.</returns>
 public virtual ICte As(IRawQuery query)
 {
     Query = query;
     return(this);
 }