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
+53-11Lines changed: 53 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,25 +58,36 @@ 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 case-sensitive and case-insensitive filtering, depending on the query. The remainder of this tutorial assumes case-insensitive database collation.
62
-
63
-
To adopt case-insensitive collation when using SQLite (<xref:Microsoft.EntityFrameworkCore.SqliteDbContextOptionsBuilderExtensions.UseSqlite%2A> is called in `Program.cs`), open the `Data/BlazorWebAppMoviesContext.cs` file. Inside the `BlazorWebAppMoviesContext` class, add the following code:
The <xref:System.Linq.Queryable.Where%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.
71
62
72
63
Run the app and navigate to the movies `Index` page at `/movies`. The movies in the database load:
73
64
74
65

75
66
67
+
:::zone pivot="vs"
68
+
76
69
Append a query string to the URL in the address bar: `?titleFilter=road+warrior`. For example, the full URL appears as `https://localhost:7073/movies?titleFilter=road+warrior`, assuming the port number is `7073`. The filtered movie is displayed:
77
70
78
71

79
72
73
+
:::zone-end
74
+
75
+
:::zone pivot="vsc"
76
+
77
+
Append a query string to the URL in the address bar: `?titleFilter=Road+Warrior`. For example, the full URL appears as `https://localhost:7073/movies?titleFilter=Road+Warrior`, assuming the port number is `7073`. The filtered movie is displayed:
78
+
79
+

80
+
81
+
:::zone-end
82
+
83
+
:::zone pivot="cli"
84
+
85
+
Append a query string to the URL in the address bar: `?titleFilter=Road+Warrior`. For example, the full URL appears as `https://localhost:7073/movies?titleFilter=Road+Warrior`, assuming the port number is `7073`. The filtered movie is displayed:
86
+
87
+

88
+
89
+
:::zone-end
90
+
80
91
Next, give users a way to provide the `titleFilter` filter string via the component's UI. Add the following HTML under the H1 heading (`<h1>Index</h1>`). The following HTML reloads the page with the contents of the textbox as a query string value:
81
92
82
93
```html
@@ -108,6 +119,8 @@ Because the app is currently running with `dotnet watch`, saved changes are dete
108
119
109
120
:::zone-end
110
121
122
+
:::zone pivot="vs"
123
+
111
124
Type "`road warrior`" into the search box and select the **:::no-loc text="Search":::** button to filter the movies:
112
125
113
126

@@ -118,6 +131,36 @@ The result after searching on `road warrior`:
118
131
119
132
Notice that the search box loses the search value ("`road warrior`") when the movies are filtered. If you want to preserve the searched value, add the `data-permanent` attribute:
120
133
134
+
:::zone-end
135
+
136
+
:::zone pivot="vsc"
137
+
138
+
Type "`Road Warrior`" into the search box and select the **:::no-loc text="Search":::** button to filter the movies:
139
+
140
+

141
+
142
+
The result after searching on `Road Warrior`:
143
+
144
+

145
+
146
+
Notice that the search box loses the search value ("`Road Warrior`") when the movies are filtered. If you want to preserve the searched value, add the `data-permanent` attribute:
147
+
148
+
:::zone-end
149
+
150
+
:::zone pivot="cli"
151
+
152
+
Type "`Road Warrior`" into the search box and select the **:::no-loc text="Search":::** button to filter the movies:
153
+
154
+

155
+
156
+
The result after searching on `Road Warrior`:
157
+
158
+

159
+
160
+
Notice that the search box loses the search value ("`Road Warrior`") when the movies are filtered. If you want to preserve the searched value, add the `data-permanent` attribute:
Copy file name to clipboardExpand all lines: aspnetcore/blazor/tutorials/movie-database-app/part-8.md
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -191,10 +191,30 @@ In its place, add the following Razor markup:
191
191
192
192
`@bind:event="oninput"` performs binding for the HTML's `oninput` event, which fires when the `<input>` element's value is changed as a direct result of a user typing in the search box. The QuickGrid is bound to `FilteredMovies`. As `titleFilter` changes with the value of the search box, rerendering the QuickGrid bound to the `FilteredMovies` method filters movie entities based on the updated value of `titleFilter`.
193
193
194
+
:::zone pivot="vs"
195
+
194
196
Run the app, type "`road warrior`" into the search field and notice how the QuickGrid is filtered for each character entered until *The Road Warrior* movie is left when the search field reaches "`road `" (":::no-loc text="road":::" followed by a space).
195
197
196
198

197
199
200
+
:::zone-end
201
+
202
+
:::zone pivot="vsc"
203
+
204
+
Run the app, type "`Road Warrior`" into the search field and notice how the QuickGrid is filtered for each character entered until *The Road Warrior* movie is left when the search field reaches "`Road `" (":::no-loc text="Road":::" followed by a space).
205
+
206
+

207
+
208
+
:::zone-end
209
+
210
+
:::zone pivot="cli"
211
+
212
+
Run the app, type "`Road Warrior`" into the search field and notice how the QuickGrid is filtered for each character entered until *The Road Warrior* movie is left when the search field reaches "`Road `" (":::no-loc text="Road":::" followed by a space).
213
+
214
+

215
+
216
+
:::zone-end
217
+
198
218
Filtering database records is performed on the server, and the server interactively sends back the HTML to display over the same SignalR connection. The page doesn't reload. The user feels like their interactions with the page are running code on the client. Actually, the code is running the server.
199
219
200
220
Instead of an HTML form, submitting a GET request in this scenario could've also used JavaScript to submit the request to the server, either using the [Fetch API](https://developer.mozilla.org/docs/Web/API/Fetch_API)` or [XMLHttpRequest API](https://developer.mozilla.org/docs/Web/API/XMLHttpRequest). In most cases, JavaScript can be replaced by using Blazor and C# in an interactive component.
Formoreinformation, see [Quickstart: Use .NET to create a blob in object storage](/azure/storage/blobs/storage-quickstart-blobs-dotnet). Thetopicdemonstrates <xref:Microsoft.Azure.Storage.File.CloudFile.UploadFromFileAsync*>, but <xref:Microsoft.Azure.Storage.File.CloudFile.UploadFromStreamAsync*> canbeusedtosavea <xref:System.IO.FileStream> toblobstorage when working with a <xref:System.IO.Stream>.
1597
+
Formoreinformation, see [Quickstart: Use .NET to create a blob in object storage](/azure/storage/blobs/storage-quickstart-blobs-dotnet). Thetopicdemonstrates <xref:Microsoft.Azure.Storage.File.CloudFile.UploadFromFileAsync%2A>, but <xref:Microsoft.Azure.Storage.File.CloudFile.UploadFromStreamAsync%2A> canbeusedtosavea <xref:System.IO.FileStream> toblobstorage when working with a <xref:System.IO.Stream>.
0 commit comments