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: nservicebus/handlers/accessing-data.md
+7-4Lines changed: 7 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,21 +15,24 @@ related:
15
15
- persistence/azure-table
16
16
---
17
17
18
-
In most cases, [handlers](/nservicebus/handlers/) are used to modify the internal state of an application based on the content of a received message. In any system, it is critical to ensure the state change happens exactly once. In a messaging system, this can be challenging as exactly-once delivery is not guaranteed by many queuing technologies. NServiceBus provides several strategies to mitigate the risk of a handler leaving the application on an inconsistent state.
18
+
In most cases, [handlers](/nservicebus/handlers/) are used to modify the internal state of an application based on the content of a received message. In any system, it is critical to ensure the state change happens exactly once. In a messaging system, this can be challenging as exactly-once delivery is not guaranteed by many queuing technologies. NServiceBus provides several strategies to mitigate the risk of a handler leaving the application in an inconsistent state.
19
19
20
20
Accessing the application state can be achieved in a number of ways and is not enforced or restricted by using NServiceBus.
21
21
22
-
The section below provides guidance on several ways of accessing the application state by using the same data context as NServiceBus uses internally.
22
+
The section below outlines several ways to access the application state using the same data context NServiceBus use internally.
23
23
24
24
partial: transactionscope
25
25
26
26
### Object/relational mappers
27
27
28
-
When using an object/relational mapper (ORM) like [Entity Framework](https://en.wikipedia.org/wiki/Entity_Framework) for data access, there is the ability to either inject the data context object via dependency injection or create a data context on the fly and reuse the connection.
28
+
When using an object/relational mapper (ORM) like [Entity Framework](https://en.wikipedia.org/wiki/Entity_Framework) for data access, the two primary options are:
29
+
30
+
1. Create a data context on the fly and reuse the connection
31
+
2. Inject the data context object via dependency injection
29
32
30
33
Creating a data context on the fly means that any other handler will work disconnected from that data context. This is a fairly simple approach, but it is not recommended when the same message is processed by multiple handlers.
31
34
32
-
If multiple handlers processing a single message is a requirement, then it is recommended to inject the data context of an ORM via dependency injection. More information can be found in the SQL persistence documentation about [accessing data](/persistence/sql/accessing-data.md).
35
+
If multiple handlers processing a single message is required, injecting the data context object via dependency injection is recommended. More information can be found in the SQL persistence documentation about [accessing data](/persistence/sql/accessing-data.md).
0 commit comments