Hey.
I am using:
- SQL Server 2005
- VS 2008
- .Net 3.5
- LLBLGen 2.6.8.819 (Self Servicing - Two classes)
I had a whole bunch of logic on the Save method of an Entity, e.g ResultEntity, which worked fine.
I then noticed that the overridden Save method of the ResultEntity is not called when the entity is recursively saved from another Entity. i.e:
SampleEntity s = new SampleEntity();
s.Number = 1337;
ResultEntity r1 = new ResultEntity();
r1.Value = 1337;
s.Result.Add(r1);
ResultEntity r2 = new ResultEntity();
r2.Value = 1337;
s.Result.Add(r2);
s.Save(true);
So I decided to spit the code in the Save method of the ResultEntity into the InsertEntity and UpdateEntity methods (which i guess should have been done from the start).
We are looking at the Save() method of the ResultEntity.
public override bool Save(IPredicate updateRestriction, bool recurse)
{
if (Comment == null || CommentId == Guid.Empty)
{
Comment = new CommentEntity();
Comment.Description = "Description";
}
return base.Save(updateRestriction, recurse);
}
Which now is in the InsertEntity method of the ResultEntity like so:
protected override bool InsertEntity()
{
if (Comment == null || CommentId == Guid.Empty)
{
Comment = new CommentEntity();
Comment.Description = "Description";
}
return base.InsertEntity();
}
But the CommentEntity is now not saved anymore?
Do I explicitly have to call the Save() on the Comment after setting the "Description" in the InsertEntity? And if so, will it still be a part of the internal transaction that the Sample/Result entities use in the first code snippet I pasted.
Thanks.