SuperGURU
SuperGURU

Reputation: 25

Linq2Db using a Column in an Update Statement

I want to recreate the following SQL Update Command in LINQ to DB (Linq2DB).

UPDATE MyTable
SET TextColumn = CONCAT(TextColumn, char(13), char(10), 'New Text')
WHERE TextColum IS NOT NULL

I don't know how to implement this with Linq2Db because I don't know how to get access to the Column to use it as a Value.

using (var db = new DbNorthwind())
{
  db.MyTable
    .Where(p => p.TextColumn != null)
    .Set(p => p.TextColumn, ???)    
    .Update();
}

Upvotes: 0

Views: 359

Answers (1)

Svyatoslav Danyliv
Svyatoslav Danyliv

Reputation: 27366

Nothing special here, just repeat what to do with column.

using (var db = new DbNorthwind())
{
    db.MyTable
        .Where(p => p.TextColumn != null)
        .Set(p => p.TextColumn, p => p.TextColumn + "New Text")    
        .Update();
}

Upvotes: 3

Related Questions