From d6e775b85aac69fd6822ed00cace451d0232b67f Mon Sep 17 00:00:00 2001 From: adospace Date: Wed, 28 Aug 2024 10:41:21 +0200 Subject: [PATCH] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1c3abc7..76879f4 100644 --- a/README.md +++ b/README.md @@ -42,28 +42,28 @@ partial class Todo Get the model context from the container ```csharp -var _modelContext = serviceProvider.GetService(); +var modelContext = serviceProvider.GetService(); ``` Create a Query for the model: ```csharp -var _query = _modelContext.Query(); +var query = modelContext.Query(); ``` A query is an object implementing INotifyCollectionChanged that notifies subscribers of any change to the list of models contained in the context. You can freely create a query with custom linq, ordering results as you prefer: ```csharp -var _query = _modelContext.Query(_=>_.Where(x => x.Done).OrderBy(x => x.Title)); +var query = modelContext.Query(_=>_.Where(x => x.Done).OrderBy(x => x.Title)); ``` Notifications are raised only for those models that pass the filter and in the order specified. Now just add an entity to your context and the query will receive the notification. ```csharp -_modelContext.Add(new Todo { Title = "Task 1" }); -_modelContext.Save(); +modelContext.Add(new Todo { Title = "Task 1" }); +modelContext.Save(); ``` Note that the `Save()` function is synchronous, it just signals to the context that you modified it. Entities are sent to the storage in a separate background thread.