Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 091dbd8

Browse files
committed
Add UpdateOnly test updating multiple columns
1 parent c2cd310 commit 091dbd8

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/ServiceStack.OrmLite.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -910,8 +910,8 @@ Global
910910
{9A5CCB1A-D127-41D1-9F25-91848E60672B}.Release|x86.ActiveCfg = Release|Any CPU
911911
{9A5CCB1A-D127-41D1-9F25-91848E60672B}.Signed|Any CPU.ActiveCfg = Release|Any CPU
912912
{9A5CCB1A-D127-41D1-9F25-91848E60672B}.Signed|Any CPU.Build.0 = Release|Any CPU
913-
{9A5CCB1A-D127-41D1-9F25-91848E60672B}.Signed|Mixed Platforms.ActiveCfg = Release|Any CPU
914-
{9A5CCB1A-D127-41D1-9F25-91848E60672B}.Signed|Mixed Platforms.Build.0 = Release|Any CPU
913+
{9A5CCB1A-D127-41D1-9F25-91848E60672B}.Signed|Mixed Platforms.ActiveCfg = Signed|Any CPU
914+
{9A5CCB1A-D127-41D1-9F25-91848E60672B}.Signed|Mixed Platforms.Build.0 = Signed|Any CPU
915915
{9A5CCB1A-D127-41D1-9F25-91848E60672B}.Signed|x86.ActiveCfg = Release|Any CPU
916916
{1BCE2206-A9F9-4381-B4F7-F617998447A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
917917
{1BCE2206-A9F9-4381-B4F7-F617998447A1}.Debug|Any CPU.Build.0 = Debug|Any CPU

tests/ServiceStack.OrmLite.Tests/OrmLiteUpdateTests.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Data;
4+
using System.Linq;
45
using NUnit.Framework;
56
using ServiceStack.Common.Tests.Models;
7+
using ServiceStack.OrmLite.Tests.Shared;
68
using ServiceStack.Text;
79

810
namespace ServiceStack.OrmLite.Tests
@@ -136,5 +138,26 @@ public void Can_Update_Many_Into_Table_With_Id_Only()
136138
var list = new List<ModelWithIdOnly> { row1, row2 };
137139
db.UpdateAll(list);
138140
}
141+
142+
[Test]
143+
public void Can_UpdateOnly_multiple_columns()
144+
{
145+
db.DropAndCreateTable<Person>();
146+
147+
db.Insert(new Person { FirstName = "FirstName", Age = 100 });
148+
149+
var existingPerson = db.Select<Person>().First();
150+
151+
existingPerson.FirstName = "JJ";
152+
existingPerson.Age = 12;
153+
154+
db.UpdateOnly(existingPerson,
155+
onlyFields: p => new { p.FirstName, p.Age });
156+
157+
var person = db.Select<Person>().First();
158+
159+
Assert.That(person.FirstName, Is.EqualTo("JJ"));
160+
Assert.That(person.Age, Is.EqualTo(12));
161+
}
139162
}
140163
}

0 commit comments

Comments
 (0)