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: docs/caveats.md
+26-3Lines changed: 26 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,19 @@ NULL is a very special value in databases. You can't compare against it as it in
6
6
7
7
This is why having a nullable column as part of the keyset _is not supported_ in this library, as we can't predictably deal with its special handling in databases.
8
8
9
-
### Workaround
9
+
### Solutions
10
+
11
+
There are two solutions for this:
12
+
1. Computed column: Reliable, performant, a bit harder to implement
13
+
2. Coalescing in keyset: Extremely easy to implement, but might suffer in terms of performance
14
+
15
+
#### Solution #1 - Computed column
10
16
11
17
The recommended way of working around this when you naturally have a nullable column that you want as part of your keyset is through using a non-nullable computed column (one for each nullable column in your keyset) and using that in your keyset instead.
12
18
13
19
You'll have to do this with any kind of nullable column type, but let's look at an example for a DateTime column.
14
20
15
-
Let's assume we want to create a keyset comprising of two columns: Created + Id. Let's assume that we need to make Created nullable for a business requirement.
21
+
Let's assume we want to create a keyset comprising of two columns: `Created` + `Id`. Let's assume that we need to make `Created` nullable for a business requirement.
16
22
17
23
First, we'll need to introduce a property in our model that we'll configure as computed along our nullable property:
Check this [sample page](../samples/Basic/Pages/Computed.cshtml) for a working example you can run and play with.
78
+
79
+
#### Solution #2 - Coalescing in keyset
80
+
81
+
This is an extremely easy solution to the NULL problem. Let's assume again we have the following keyset: `Created` + `Id`, where `Created` is nullable.
0 commit comments