Zoli
How to Properly Synchronize ViewModel and Model in MVVM (CommunityToolkit.Mvvm)
In a reactive approach for an edit operation, FooModel is passed to FooViewModel via the constructor. However, this means that any modifications made in the ViewModel will be directly reflected in the original model, even if the user cancels the operation without saving.
How can I ensure that changes are only applied to the original model after a successful save operation while still leveraging reactivity? What is the best practice for maintaining the original state if the user decides to discard the changes?
7 replies
✅ UNIQUE constraint failed
Ohhh looks good thanks a lot 🍻
Probably it will solve my issue. One more question if you dont mind. I have the ExerciseVariant table which is kind of metadata so only read only.
Do I need this list of exercise at all?
Each exercise can have one exercise variant, and exercise variant can be used for multiple exercise
21 replies
✅ UNIQUE constraint failed
When I want to create a workout:
I am getting an exception as
An error occurred while saving the entity changes.See the inner exception for details. // ---> Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 19: 'UNIQUE constraint failed: ExerciseVariant.Id'.What am I doing worng? Since
ExerciseVariant
is read only kind of metadata do I need to add ?
public ICollection<Exercise> Exercises { get; } = new List<Exercise>();
21 replies
Determining Feed Ownership for Edit/Delete Functionality in a client application
Thank you for the input!. Ovbiously on the server side i still need to validate the incoming edit/delete request for particular feedItem (does the authenticated user own the target feed item).
4 replies
Resolving Entity Framework Core Tracking Issues with Shared Relationships in .NET MAUI and SQLite
Data Context Configuration:
The Issue:
When I attempt to create a workout and associate it with an existing ExerciseVariant, I encounter the following error:
The instance of entity type 'ExerciseVariant' cannot be tracked because another instance with the same key value for {'Id'} is already being tracked.
I have already tried using AsNoTracking when retrieving the ExerciseVariant, but the issue persists.
How can i solve this issue? Is there a recommended way to handle such scenarios where an entity with shared relationships needs to be reused?
6 replies