|
1 | | -* New Update and UpdateAsync upgrade: CASE |
| 1 | +# New Update and UpdateAsync upgrade: CASE |
2 | 2 |
|
3 | | -** A new feature added to allow developers to programmatically set CASE WHEN when assigning values. Feature includes grouping in sub statements () or |
4 | | -** to allow condition to point to a column variable instead of a direct paramater value. SQL injection friendly |
| 3 | +## A new feature added to allow developers to programmatically set CASE WHEN when assigning values. Feature includes grouping in sub statements () or |
| 4 | +## to allow condition to point to a column variable instead of a direct paramater value. SQL injection friendly |
5 | 5 |
|
6 | | -** Original Update Statement for multiple records using anonymous objects: |
| 6 | +## Original Update Statement for multiple records using anonymous objects: |
7 | 7 |
|
8 | | -*** foreach (var item in data) |
| 8 | +### foreach (var item in data) |
9 | 9 |
|
10 | | -*** { |
| 10 | +### { |
11 | 11 |
|
12 | | -*** object obj = new |
| 12 | +### object obj = new |
13 | 13 |
|
14 | | -*** { |
| 14 | +### { |
15 | 15 |
|
16 | | -*** MyField = item.Value |
| 16 | +### MyField = item.Value |
17 | 17 |
|
18 | | -*** }; |
| 18 | +### }; |
19 | 19 |
|
20 | | -*** cnt += await QueryFactory.Query(tableName).Where("Id", item.Id).UpdateAsync(value); |
| 20 | +### cnt += await QueryFactory.Query(tableName).Where("Id", item.Id).UpdateAsync(value); |
21 | 21 | |
22 | 22 |
|
23 | | -*** } |
| 23 | +### } |
24 | 24 |
|
25 | | -*** return cnt; |
| 25 | +### return cnt; |
26 | 26 |
|
27 | 27 |
|
28 | 28 |
|
29 | 29 |
|
30 | 30 |
|
31 | | -** New Update with select case using multi-level array systems |
32 | | -** version 1 : allows is equal condition only for now |
33 | | -** For the Else it will always fill with name of field itself , self assigning. |
34 | | -** This happens if format is wrong as well. |
35 | | -** The else protects you fro your field to be set back to NULL |
| 31 | +## New Update with select case using multi-level array systems |
| 32 | +## version 1 : allows is equal condition only for now |
| 33 | +## For the Else it will always fill with name of field itself , self assigning. |
| 34 | +## This happens if format is wrong as well. |
| 35 | +## The else protects you fro your field to be set back to NULL |
36 | 36 | |
37 | | -*** Warning: Limitation is requires , Suggest 200 rows for low number columns, |
38 | | -*** 25 for higher number columns or clauses. |
| 37 | +### Warning: Limitation is requires , Suggest 200 rows for low number columns, |
| 38 | +### 25 for higher number columns or clauses. |
39 | 39 |
|
40 | 40 |
|
41 | 41 | var datac = data.Chunk(200); // breaking data up to 200 rows |
|
73 | 73 |
|
74 | 74 |
|
75 | 75 |
|
76 | | -**standard: Case WHEN x = A then Y... END: |
77 | | -*** In your cases array the flow is [x,A,Y]. |
78 | | -*** Assignmet value is always last. |
| 76 | +##standard: Case WHEN x = A then Y... END: |
| 77 | +### In your cases array the flow is [x,A,Y]. |
| 78 | +### Assignmet value is always last. |
79 | 79 |
|
80 | 80 |
|
81 | 81 |
|
82 | 82 |
|
83 | 83 |
|
84 | | -** Available Feaure 1 : While its common to do 3 items for basic, when can extend the criteria with AND and OR |
85 | | -** It combine, the array column after the orevioud criteria field must be an AND or OR, unless using , () or * explained later |
| 84 | +## Available Feaure 1 : While its common to do 3 items for basic, when can extend the criteria with AND and OR |
| 85 | +## It combine, the array column after the orevioud criteria field must be an AND or OR, unless using , () or * explained later |
86 | 86 |
|
87 | | -*** Note: Assignmet value is always last. you can use AND,&&,& or OR,||,|, <>. Not case sensitive. |
| 87 | +### Note: Assignmet value is always last. you can use AND,&&,& or OR,||,|, <>. Not case sensitive. |
88 | 88 |
|
89 | | -*** Case WHEN x = A AND z = B then Y ... END: |
90 | | -*** In your cases array the flow is [x,A,"AND",z,B,Y] |
91 | | -*** Case WHEN x = A OR z = B then Y ... END: |
92 | | -*** Array the flow is [x,A,"OR",z,B,Y] |
| 89 | +### Case WHEN x = A AND z = B then Y ... END: |
| 90 | +### In your cases array the flow is [x,A,"AND",z,B,Y] |
| 91 | +### Case WHEN x = A OR z = B then Y ... END: |
| 92 | +### Array the flow is [x,A,"OR",z,B,Y] |
93 | 93 |
|
94 | 94 |
|
95 | 95 |
|
96 | 96 |
|
97 | 97 |
|
98 | | -** Available Feaure 2 : Subset (). This allows seperating your "And" & "Or" blocks |
99 | | -*** ex: case when (a = 1 or a = 5) and (b = 7 and c = 2) |
100 | | -*** This can be placed anywhere before the assignment column or * assignment column, |
101 | | -*** if you forget to add the ) to close, the engine |
102 | | -*** will compensate. |
| 98 | +## Available Feaure 2 : Subset (). This allows seperating your "And" & "Or" blocks |
| 99 | +### ex: case when (a = 1 or a = 5) and (b = 7 and c = 2) |
| 100 | +### This can be placed anywhere before the assignment column or * assignment column, |
| 101 | +### if you forget to add the ) to close, the engine |
| 102 | +### will compensate. |
103 | 103 |
|
104 | | -*** Case WHEN (x = A AND z = B) OR J = C then Y ... END: |
105 | | -*** Array the flow is ["(",x,A,"AND",z,B,")","OR",j,c,Y] |
106 | | -*** Case WHEN (x = A OR z = B) AND (J = C AND K = D) then Y ... END: |
107 | | -*** Array the flow is ["(",x,A,"OR",z,B,")","AND","(",j,c,"AND",k,d,")" Y] |
| 104 | +### Case WHEN (x = A AND z = B) OR J = C then Y ... END: |
| 105 | +### Array the flow is ["(",x,A,"AND",z,B,")","OR",j,c,Y] |
| 106 | +### Case WHEN (x = A OR z = B) AND (J = C AND K = D) then Y ... END: |
| 107 | +### Array the flow is ["(",x,A,"OR",z,B,")","AND","(",j,c,"AND",k,d,")" Y] |
108 | 108 |
|
109 | 109 |
|
110 | | -** Available Feaure 3 : To Another Column Field (*). This allows criteria to check if column equals another column (field) |
111 | | -*** Case WHEN (colx = colb AND colz = colx) then Y ... END: |
112 | | -*** Array the flow is [,colx,*',colb,"AND",colz,colx, Y] |
| 110 | +## Available Feaure 3 : To Another Column Field (*). This allows criteria to check if column equals another column (field) |
| 111 | +### Case WHEN (colx = colb AND colz = colx) then Y ... END: |
| 112 | +### Array the flow is [,colx,*',colb,"AND",colz,colx, Y] |
0 commit comments