direct sql?

Posts   
 
    
cyclej
User
Posts: 5
Joined: 29-Mar-2010
# Posted on: 21-Jun-2010 23:32:20   

Is there a way to use the adapter to accomplish something like this:

UPDATE my-table SET column1 = column2 WHERE some-condition;

It looks like the UpdateEntitiesDirectly or UnitOfWork are close to what I need, but the examples I've found set "column1" to a "constant", not another "column".

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 22-Jun-2010 02:19:18   

This is an example:

// C# and Adapter
EmployeeEntity employee = new EmployeeEntity();
employee.Fields[(int)EmployeeFieldIndex.Salary].ExpressionToApply = EmployeeFields.BaseSalary;
DataAccessAdapter adapter = new DataAccessAdapter();
// no filter is specified, everybody gets 10% extra, but you could of course
// specify a filter to limit the scope of the update.
adapter.UpdateEntitiesDirectly(employee, null);

This was extracted from Expressions in entity updates.

David Elizondo | LLBLGen Support Team