Skip to content

Commit d780b31

Browse files
Fix for Issue MikaelEliasson#50: Don't include TPH discriminator in UpdateAll
1 parent 27df1b5 commit d780b31

File tree

3 files changed

+41
-11
lines changed

3 files changed

+41
-11
lines changed

EntityFramework.Utilities/EntityFramework.Utilities/EFBatchOperation.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,6 @@ public void UpdateAll<TEntity>(IEnumerable<TEntity> items, Action<UpdateSpecific
164164
IsPrimaryKey = p.IsPrimaryKey
165165
}).ToList();
166166

167-
if (tableMapping.TPHConfiguration != null)
168-
{
169-
properties.Add(new ColumnMapping
170-
{
171-
NameInDatabase = tableMapping.TPHConfiguration.ColumnName,
172-
StaticValue = tableMapping.TPHConfiguration.Mappings[typeof(TEntity)]
173-
});
174-
}
175-
176167
var spec = new UpdateSpecification<TEntity>();
177168
updateSpecification(spec);
178169
provider.UpdateItems(items, tableMapping.Schema, tableMapping.TableName, properties, connectionToUse, batchSize, spec);

EntityFramework.Utilities/EntityFramework.Utilities/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("1.0.0.0")]
35+
[assembly: AssemblyVersion("1.0.1.0")]
36+
[assembly: AssemblyFileVersion("1.0.1.0")]

EntityFramework.Utilities/Tests/UpdateBulkTests.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,45 @@ public void UpdateBulk_UpdatesAll()
3636
}
3737
}
3838

39+
[TestMethod]
40+
public void UpdateBulk_CanUpdateTPH()
41+
{
42+
using (var db = Context.Sql())
43+
{
44+
if (db.Database.Exists())
45+
{
46+
db.Database.Delete();
47+
}
48+
db.Database.Create();
49+
50+
List<Contact> people = new List<Contact>();
51+
people.Add(Contact.Build("FN1", "LN1", "Director"));
52+
people.Add(Contact.Build("FN2", "LN2", "Associate"));
53+
people.Add(Contact.Build("FN3", "LN3", "Vice President"));
54+
55+
EFBatchOperation.For(db, db.People).InsertAll(people);
56+
}
57+
58+
using (var db = Context.Sql())
59+
{
60+
var contacts = db.Contacts.ToList();
61+
62+
foreach (var contact in contacts)
63+
{
64+
contact.FirstName = contact.Title + " " + contact.FirstName;
65+
}
66+
67+
EFBatchOperation.For(db, db.People).UpdateAll(contacts, x => x.ColumnsToUpdate(p => p.FirstName));
68+
}
69+
70+
using (var db = Context.Sql())
71+
{
72+
var contacts = db.People.OfType<Contact>().OrderBy(c => c.LastName).ToList();
73+
Assert.AreEqual(3, contacts.Count);
74+
Assert.AreEqual("Director FN1", contacts.First().FirstName);
75+
}
76+
}
77+
3978
[TestMethod]
4079
public void UpdateBulk_CanUpdateNumerics()
4180
{

0 commit comments

Comments
 (0)