You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/blazor/tutorials/movie-database-app/part-6.md
+9-10Lines changed: 9 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,14 +58,16 @@ Change the `QuickGrid` component's <xref:Microsoft.AspNetCore.Components.QuickGr
58
58
59
59
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.
60
60
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 casesensitive and caseinsensitive filtering, depending on the query. The remainder of this tutorial assumes caseinsensitive 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.
62
62
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:
67
64
68
-
For information on the best practices to adopt case insensitive SQLite queries, see the [Additional resources](#additional-resources) section of this article.
> 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
-
185
175
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.
186
176
187
177
Remove the HTML form from the component:
@@ -305,11 +295,3 @@ In the documentation website's sidebar navigation, articles are organized by sub
305
295
306
296
> [!div class="step-by-step"]
307
297
> [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