sami wrote:
Maybe you guys could help me out with this one.
So, if I apply .ExpressionToApply to my field, like this:
entity.Fields["somefield"].ExpressionToApply = someExpression;
The expression is then applied to update statement and predicate?
No, it's applied to the field in an UPDATE query. So if you do:
myEmployee.Fields[(int)EmployeeFieldIndex.Salary].ExpressionToApply = (EmployeeFields.Salary * 1.10f);
it will become:
UPDATE employee SET salary = (salary * 1.10) WHERE <pk filter>
What if I have the same field in both update statement AND predicate?
For example, I would like to make this kind of SQL statement:
update mytable set somefield = somefield+2 where somefield> 5
If I create code for above functionality the sql which gets executed is ;
update mytable set somefield= somefield+2 where somefield+ 2 > 5
If you re-use the field object, yes that's true.
So, the expression (somefield + 2) is applied to both update and predicate, which is not what I want to do,
Any other solutions than fetching the stuff or using stored proc?
use a new field object for the predicate:
myEmployee.Fields[(int)EmployeeFieldIndex.Salary].ExpressionToApply = (EmployeeFields.Salary * 1.10f);
IPredicate filter = (EmployeeFields.Salary > 100,000);