コード例 #1
0
        public void SqlFunctionVoidTest()
        {
            var model  = PersistentModel.Compile(@"
class a prototype=dbtable
	void GetValue @s-int=1 @v=int : (
		select @s*id+@v from @this
	)"    );
            var f      = model["a"].SqlObjects.OfType <SqlFunction>().First();
            var writer = new SqlFunctionWriter(f)
            {
                Dialect = DbDialect.SqlServer, NoComment = true
            };
            var res = writer.ToString();

            Console.WriteLine(res.Replace("\"", "\"\""));
            Assert.AreEqual(@"IF OBJECT_ID('""dbo"".""aGetValue""') IS NOT NULL DROP PROCEDURE ""dbo"".""aGetValue"";
GO
CREATE PROCEDURE ""dbo"".""aGetValue"" @s int = '1',@v int = null  AS BEGIN
select @s*id+@v from ""dbo"".""a""
END;
GO".Trim(), res.Trim());
        }
コード例 #2
0
        public void SqlFunctionTestWithFuncReference()
        {
            var model  = PersistentModel.Compile(@"
class a prototype=dbtable
	int GetValue @s-int=1 @v=int : (
		exec @this.proc
		return (select @s*id+@v + @this.GetValue(@s,@v) from @this where @this.Id=0)
	)"    );
            var f      = model["a"].SqlObjects.OfType <SqlFunction>().First();
            var writer = new SqlFunctionWriter(f)
            {
                Dialect = DbDialect.SqlServer, NoComment = true
            };
            var res = writer.ToString();

            Console.WriteLine(res.Replace("\"", "\"\""));
            Assert.AreEqual(@"IF OBJECT_ID('""dbo"".""aGetValue""') IS NOT NULL DROP FUNCTION ""dbo"".""aGetValue"";
GO
CREATE FUNCTION ""dbo"".""aGetValue"" ( @s int = '1',@v int = null  ) RETURNS int AS BEGIN
exec ""dbo"".""aproc""
		return (select @s*id+@v + ""dbo"".""aGetValue""(@s,@v) from ""dbo"".""a"" where ""dbo"".""a"".Id=0)
END;
GO".Trim().Simplify(SimplifyOptions.LfOnly), res.Trim().Simplify(SimplifyOptions.LfOnly));
        }
コード例 #3
0
ファイル: WritersTest.cs プロジェクト: Qorpent/qorpent.sys
		public void SqlFunctionVoidTest()
		{
			var model = PersistentModel.Compile(@"
class a prototype=dbtable
	void GetValue @s-int=1 @v=int : (
		select @s*id+@v from @this
	)");
			var f = model["a"].SqlObjects.OfType<SqlFunction>().First();
			var writer = new SqlFunctionWriter(f) { Dialect = DbDialect.SqlServer,NoComment = true};
			var res = writer.ToString();
			Console.WriteLine(res.Replace("\"", "\"\""));
			Assert.AreEqual(@"IF OBJECT_ID('""dbo"".""aGetValue""') IS NOT NULL DROP PROCEDURE ""dbo"".""aGetValue"";
GO
CREATE PROCEDURE ""dbo"".""aGetValue"" @s int = '1',@v int = null  AS BEGIN
select @s*id+@v from ""dbo"".""a""
END;
GO".Trim(), res.Trim());
		}
コード例 #4
0
ファイル: WritersTest.cs プロジェクト: Qorpent/qorpent.sys
		public void SqlFunctionTestWithFuncReference()
		{
			var model = PersistentModel.Compile(@"
class a prototype=dbtable
	int GetValue @s-int=1 @v=int : (
		exec @this.proc
		return (select @s*id+@v + @this.GetValue(@s,@v) from @this where @this.Id=0)
	)");
			var f = model["a"].SqlObjects.OfType<SqlFunction>().First();
			var writer = new SqlFunctionWriter(f) { Dialect = DbDialect.SqlServer, NoComment = true };
			var res = writer.ToString();
			Console.WriteLine(res.Replace("\"", "\"\""));
			Assert.AreEqual(@"IF OBJECT_ID('""dbo"".""aGetValue""') IS NOT NULL DROP FUNCTION ""dbo"".""aGetValue"";
GO
CREATE FUNCTION ""dbo"".""aGetValue"" ( @s int = '1',@v int = null  ) RETURNS int AS BEGIN
exec ""dbo"".""aproc""
		return (select @s*id+@v + ""dbo"".""aGetValue""(@s,@v) from ""dbo"".""a"" where ""dbo"".""a"".Id=0)
END;
GO".Trim().Simplify(SimplifyOptions.LfOnly), res.Trim().Simplify(SimplifyOptions.LfOnly));
		}