Пример #1
0
        public void EnumerableContains_with_non_unicode_string_and_csharp_null_is_translated_to_expected_sql()
        {
            const string expectedSql =
                @"SELECT 
[Extent1].[Id] AS [Id]
FROM [dbo].[Books] AS [Extent1]
WHERE (([Extent1].[Title] IN ('Title1', 'Title2')) AND ([Extent1].[Title] IS NOT NULL)) 
    OR ([Extent1].[Title] IS NULL)";

            var array = new[] { "Title1", "Title2", null };

            using (var context = new NonUnicodeContext())
            {
                ((IObjectContextAdapter)context).ObjectContext.ContextOptions.UseCSharpNullComparisonBehavior = true;

                var query = from book in context.Books
                            where array.Contains(book.Title)
                            select book.Id;

                QueryTestHelpers.VerifyDbQuery(query, expectedSql);
            }
        }
Пример #2
0
        public void EnumerableContains_with_non_unicode_string_and_csharp_null_is_translated_to_expected_sql()
        {
            const string expectedSql =
                @"SELECT 
[Extent1].[Id] AS [Id]
FROM [dbo].[Books] AS [Extent1]
WHERE (([Extent1].[Title] IN ('Title1', 'Title2')) AND ([Extent1].[Title] IS NOT NULL)) 
    OR ([Extent1].[Title] IS NULL)";

            var array = new[] { "Title1", "Title2", null };

            using (var context = new NonUnicodeContext())
            {
                ((IObjectContextAdapter)context).ObjectContext.ContextOptions.UseCSharpNullComparisonBehavior = true;

                var query = from book in context.Books
                            where array.Contains(book.Title)
                            select book.Id;

                QueryTestHelpers.VerifyDbQuery(query, expectedSql);
            }
        }