Hi there,
I am using:
Version: LLBLGen Pro 2.6 Final
SD.Presets.SelfServicing.General2008 with merged AdditionalTemplates.LinqADODS
I have tried a number of things, but haven't yet found the right way to do this. I am trying to calculate a field in all entities (of a specific type) before they are committed to persistent storage. I tested my logic by just modifying the SaveChanges() method in LinqMetaData.adods.cs and it worked fine. Obviously, I don't want to have my code live there as that is generated code.
I tried to override the method, but it's not virtual. I also tried to change the template to make it virtual, but then that breaks some other code in LinqMetaData.adods that relies on reflection (MethodInfo.GetType()).
So, at this point, I'm looking for a bit of guidance. What would be the best way of intercepting and modifying entities before _uow.commit() in LinqMetaData.adods?
Here's what I'm trying to accomplish, but not within generated code.
public void SaveChanges()
{
if (_transactionToUse == null)
{
_uow.ConstructSaveProcessQueues();
foreach (var s in _uow.GetInsertQueue().Where(s => s.Entity is StudyEntity))
{
var study = (StudyEntity) s.Entity;
study.Itn = "Set this to something.";
}
_uow.Commit(new Transaction(System.Data.IsolationLevel.ReadCommitted, "UOW"), true);
}
else
{
_uow.Commit(_transactionToUse, true);
}
}
Thanks very much for your help.
Philip