Craig W.
Craig W.

Reputation: 18155

EntityFramework.Extended Update - Trying to set one column to another

I'm using the EntityFramework.Extended library to try to bulk update a table. It works great if the value I'm assigning is a constant but when I try to assign one column to another it throws an exception. For example (this is contrived just to get the idea across)

// This works fine    
Update<Client>( c => c.Active, c => new Client() { DatabaseId = 100 } );

// This throws an exception
Update<Client>( c => c.Active, c => new Client() { DatabaseId = c.ClientId } );

The exception that gets thrown is

System.InvalidOperationException, variable 'c' of type 'Client' referenced from scope '', but it is not defined

Has anyone successfully done this?

Upvotes: 0

Views: 730

Answers (1)

Zach
Zach

Reputation: 31

Try this

Update<Client>( c => c.Active, nc => new Client() { DatabaseId = c.ClientId } );

Upvotes: 3

Related Questions