Update query when related entities change
See original GitHub issueIs there a way for an observable query to detect when a related entity changes, and notify its subscribers? The following uses a one-to-one relationship between a person and an address. I would like the person query to be notified when a person’s address changes.
@Entity
data class Person(@Id val id: Long = 0) {
lateinit var homeAddress: ToOne<Address>
}
@Entity
data class Address(@Id var id: Long = 0,
val street: String
)
// Build a query for the parent
val query = boxStore.boxFor<Person>().query().build()
query.find()
// I want to be notified when the address changes
query.subscribe(...)
// Update the relationship
person.homeAddress.target = Address(street= "...")
boxStore.boxFor<Address>.put(newAddress) // persists, but the person query does not get notified
This updates the address box as expected, but the person query is not notified. Any way to accomplish that?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Modifying data via the DbContext - Learn Entity Framework Core
Since the ChangeTracker tracks which properties have been modified, the context will issue a SQL statement that updates only those properties that were...
Read more >How to update related entities in Entity Framework
I solved it by changing ClassA with a foreign key to ClassB , and setting the value of BId : public class ClassA...
Read more >Change Tracking - EF Core - Microsoft Learn
EF Core change tracking works best when the same DbContext instance is used to both query for entities and update them by calling...
Read more >Update Record in Entity Framework - TekTutorialsHub
We can update records either in connected or disconnected scenarios. In the connected Scenario, we open the context, query for the entity, edit...
Read more >Modifying Data with Entity Famework Core - Code Maze
There are two ways to update rows in the database. With Connected Update and with Disconnected Update. The difference is that with the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@greenrobot-team here is the final solution i went with
let me know if there are a better workaround for rxjava. Thanks
Duplicate of #268