RecordManager entityCache
Closed this issue · 2 comments
628426 commented
The RecordManager entityCache can get out of date
// Create a record using RecordManager with either the Guid (entityId) or string (EntityName) overloads
recMan.Create("TestEntity", EntityRecord {"First Name", "Last Name"});
// Then use EntityManager to add a column
entMan.CreateField("TestEntity", "Age", ...)
// Then use the RecordManager to add another record
// fails because recMan uses a cached copy of the TestEntity (from entityCache) that doesn't have the "Age" field
recMan.Create("TestEntity", EntityRecord {"First Name", "Last Name", 21});
There is an easy workaround
// Create a record using RecordManager with either the Guid (entityId) or string (EntityName) overloads
recMan.Create("TestEntity", EntityRecord {"First Name", "Last Name"});
// Then use EntityManager to add a column
entMan.CreateField("TestEntity", "Age", ...)
// FIX: re-initialise the RecordManager
recMan = new RecordManager();
// Then use the RecordManager to add another record
// this works fine
recMan.Create("TestEntity", EntityRecord {"First Name", "Last Name", 21});
I don't have a suggested fix
rumen-yankov commented
Yeah, you are right about that problem, but we also have no easy fix. The entity schema is changed usually during patch update, so this is a rare case of Record and Entity managers usage in combination and also works fine with your workaround, so we gonna ignore it for now.
628426 commented
The entity schema is changed usually during patch update
Yes that is how I found it