Izenda-API-Tip-Constraints-Joins-Best-Practices.md
... ...
@@ -0,0 +1,19 @@
1
+- All constraints are unidirectional (or anisotropic).
2
+
3
+- Do not use simple table name without brackets, e.g. ***"Cases-Status"*** instead of ***"[Cases-Status]"***.
4
+
5
+- Please make sure that you have two constraints for the target table relationship. e.g.:
6
+```csharp
7
+AdHocContext.Driver.
8
+ AddConstraint("[dbo].[Cases-Status].[CaseID]","[dbo].[Cases-Payments].[CaseID]");
9
+AdHocContext.Driver.
10
+ AddConstraint("[dbo].[Cases-Payments].[CaseID]","[dbo].[Cases-Status].[CaseID]");
11
+```
12
+
13
+- LEFT JOIN syntax is also dependent on the 'direction' of the join. A->B produces different results than B->A. If you specify only one LEFT JOIN for Cases-Status and Cases-Payments tables then it will be used only in case when Cases-Payments table is joined to the Cases-Status table in that specific direction.
14
+
15
+ If you want it to work in **both directions** you should specify two joins:
16
+```csharp
17
+ AdHocContext.Driver.AddForcedLeftJoin("Cases-Status","Cases-Payments");
18
+ AdHocContext.Driver.AddForcedLeftJoin("Cases-Payments","Cases-Status");
19
+```