Skip to content

Commit 3c62080

Browse files
committed
Updates
1 parent f383c77 commit 3c62080

File tree

2 files changed

+9
-28
lines changed

2 files changed

+9
-28
lines changed

aspnetcore/blazor/tutorials/movie-database-app/part-6.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,16 @@ Change the `QuickGrid` component's <xref:Microsoft.AspNetCore.Components.QuickGr
5858

5959
The `movie => movie.Title!.Contains(...)` code is a *lambda expression*. Lambdas are used in method-based LINQ queries as arguments to standard query operator methods such as the <xref:System.Linq.Queryable.Where%2A> or <xref:System.String.Contains%2A> methods. LINQ queries aren't executed when they're defined or when they're modified by calling a method, such as <xref:System.Linq.Queryable.Where%2A>, <xref:System.String.Contains%2A>, or <xref:System.Linq.Queryable.OrderBy%2A>. Rather, query execution is deferred. The evaluation of an expression is delayed until its realized value is iterated.
6060

61-
The <xref:System.Data.Objects.DataClasses.EntityCollection%601.Contains%2A> method is run on the database, not in the C# code. The case sensitivity of the query depends on the database and the collation. For SQL Server, <xref:System.String.Contains%2A> maps to [SQL `LIKE`](/sql/t-sql/language-elements/like-transact-sql), which is case insensitive. SQLite with default collation provides a mixture of case sensitive and case insensitive filtering, depending on the query. The remainder of this tutorial assumes case insensitive database collation. As a workaround for case sensitive database collation with SQLite, you can adjust the Linq query to lowercase the filtering operation by applying <xref:System.String.ToLower%2A> to the movie title and the filter variable. The following workaround is purely for demonstration purposes to match the instructions and examples in this tutorial:
61+
The <xref:System.Data.Objects.DataClasses.EntityCollection%601.Contains%2A> method is run on the database, not in the C# code. The case sensitivity of the query depends on the database and the collation. For SQL Server, <xref:System.String.Contains%2A> maps to [SQL `LIKE`](/sql/t-sql/language-elements/like-transact-sql), which is case insensitive. SQLite with default collation provides a mixture of case-sensitive and case-insensitive filtering, depending on the query. The remainder of this tutorial assumes case-insensitive database collation.
6262

63-
```diff
64-
- m => m.Title!.Contains(TitleFilter ?? string.Empty)
65-
+ m => m.Title!.ToLower().Contains((TitleFilter ?? string.Empty).ToLower())
66-
```
63+
If you're following this tutorial using Visual Studio Code or the .NET CLI, you're using a SQLite database. To adopt case-insensitive collation, open the `Data/BlazorWebAppMoviesContext.cs` file. Inside the `BlazorWebAppMoviesContext` class, add the following code:
6764

68-
For information on the best practices to adopt case insensitive SQLite queries, see the [Additional resources](#additional-resources) section of this article.
65+
```csharp
66+
protected override void OnModelCreating(ModelBuilder modelBuilder)
67+
{
68+
modelBuilder.UseCollation("SQL_Latin1_General_CP1_CS_AS");
69+
}
70+
```
6971

7072
Run the app and navigate to the movies `Index` page at `/movies`. The movies in the database load:
7173

@@ -150,10 +152,7 @@ Stop the app by closing the browser's window and pressing <kbd>Ctrl</kbd>+<kbd>C
150152
* [LINQ documentation](/dotnet/csharp/programming-guide/concepts/linq/)
151153
* [Write C# LINQ queries to query data (C# documentation)](/dotnet/csharp/programming-guide/concepts/linq/query-syntax-and-method-syntax-in-linq)
152154
* [Lambda Expression (C# documentation](/dotnet/csharp/programming-guide/statements-expressions-operators/lambda-expressions)
153-
* Case insensitive SQLite queries
154-
* [How to use case-insensitive query with Sqlite provider? (`dotnet/efcore` #11414)](https://github.com/dotnet/efcore/issues/11414)
155-
* [How to make a SQLite column case insensitive (`dotnet/AspNetCore.Docs` #22314)](https://github.com/dotnet/AspNetCore.Docs/issues/22314)
156-
* [Collations and Case Sensitivity](/ef/core/miscellaneous/collations-and-case-sensitivity)
155+
* [Collations and Case Sensitivity](/ef/core/miscellaneous/collations-and-case-sensitivity)
157156

158157
## Legal
159158

aspnetcore/blazor/tutorials/movie-database-app/part-8.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,6 @@ private IQueryable<Movie> FilteredMovies =>
172172
context.Movie.Where(m => m.Title!.Contains(titleFilter));
173173
```
174174

175-
> [!NOTE]
176-
> If your database collation is case sensitive (for example, when using a SQLite database), you can lowercase the movie's title and `titleFilter` as a workaround:
177-
>
178-
> ```diff
179-
> - m => m.Title!.Contains(titleFilter)
180-
> + m => m.Title!.ToLower().Contains(titleFilter.ToLower())
181-
> ```
182-
>
183-
> For information on the best practices to adopt case insensitive SQLite queries, see the [Additional resources](#additional-resources) section of this article.
184-
185175
Next, the component should bind the `titleFilter` field to an `<input>` element, so user input is stored in the `titleFilter` variable. Binding is achieved in Blazor with the `@bind` directive attribute.
186176

187177
Remove the HTML form from the component:
@@ -305,11 +295,3 @@ In the documentation website's sidebar navigation, articles are organized by sub
305295

306296
> [!div class="step-by-step"]
307297
> [Previous: Add a new field](xref:blazor/tutorials/movie-database-app/part-7)
308-
309-
## Additional resources
310-
311-
Information and best practices to adopt case insensitive SQLite queries:
312-
313-
* [How to use case-insensitive query with Sqlite provider? (`dotnet/efcore` #11414)](https://github.com/dotnet/efcore/issues/11414)
314-
* [How to make a SQLite column case insensitive (`dotnet/AspNetCore.Docs` #22314)](https://github.com/dotnet/AspNetCore.Docs/issues/22314)
315-
* [Collations and Case Sensitivity](/ef/core/miscellaneous/collations-and-case-sensitivity)

0 commit comments

Comments
 (0)