Skip to content

Commit 86b106f

Browse files
Florian KrönertFlorian Krönert
authored andcommitted
Added plain class without generic entity type which just uses plain Entity
1 parent 0682767 commit 86b106f

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

src/lib/Xrm.Oss.UnitOfWork/UpdateContext.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
namespace Xrm.Oss.UnitOfWork
99
{
10+
public partial class UpdateContext : UpdateContext<Entity>
11+
{
12+
public UpdateContext(Entity entity) : base(entity) { }
13+
}
14+
1015
public partial class UpdateContext<T> : IDisposable where T : Entity
1116
{
1217
private T _initialState;

src/test/Xrm.Oss.UnitOfWork.Tests/UpdateContextTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,25 @@ public void Should_Add_Newly_Added_Attributes()
4848
}
4949
}
5050

51+
[Fact]
52+
public void Non_Generic_Class_Should_Fall_Back_To_Plain_Entity()
53+
{
54+
var contact = new Entity
55+
{
56+
LogicalName = "contact",
57+
Id = Guid.NewGuid()
58+
};
59+
60+
using (var updateContext = new UpdateContext(contact))
61+
{
62+
contact["firstname"] = "Frodo";
63+
64+
var update = updateContext.GetUpdateObject();
65+
66+
Assert.True(update.Contains("firstname"));
67+
}
68+
}
69+
5170
[Fact]
5271
public void Should_Not_Add_Unchanged_Attributes()
5372
{

0 commit comments

Comments
 (0)