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)); }
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()); }
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()); }
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); }
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); }
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); })); }
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); }
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); }
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");
public virtual IEnumerable <T> RawQuery <T>(IRawQuery query) where T : class { return(Try(() => OnRawQueryAs <T, T>(query))); }
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()); }
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 void Visit(IRawQuery filter) => Write("raw");
/// <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); }