Exemple #1
0
        public void TsQueryOr()
        {
            using (var context = new BloggingContext(ConnectionString))
            {
                context.Database.Log = Console.Out.WriteLine;

                context.Blogs.Add(new Blog {
                    Name = "_"
                });
                context.SaveChanges();

                var result = context.Blogs.Select(
                    x => NpgsqlTextFunctions.QueryOr(
                        NpgsqlTextFunctions.AsTsQuery("fat | rat"),
                        NpgsqlTextFunctions.AsTsQuery("cat"))).First();

                Assert.That(
                    NpgsqlTsQuery.Parse(result).ToString(),
                    Is.EqualTo(NpgsqlTsQuery.Parse("( 'fat' | 'rat' ) | 'cat'").ToString()));

                result = context.Blogs.Select(
                    x => NpgsqlTextFunctions.AsTsQuery("fat | rat")
                    + NpgsqlTextFunctions.AsTsQuery("cat")).First();

                Assert.That(
                    NpgsqlTsQuery.Parse(result).ToString(),
                    Is.EqualTo(NpgsqlTsQuery.Parse("( 'fat' | 'rat' ) | 'cat'").ToString()));
            }
        }