Hello,
workring on .NET 2.0 and llblgen 2.0 (adapter) i've got a problem saving a entity. I've overwritten the event OnBeforeEntitySave of my entity "TblFirmenEntity". In my function i want to add a child entity "TblAbtZEntity" to TblFirmenEntity. Every things works. the count of the entitycollection "TblAbtZ" is increased. My problem is that the dataaccessadapter doesn't save it. I think he don't know the added entity. When i add it manually from the winform before calling the adapter.saveentity(TblFirmenEntity) it works. Is there any Method to tell the dataadapter that the child entity collection has changed or new members?
public partial class TblFirmenEntity
{
protected override void OnBeforeEntitySave()
{
base.OnBeforeEntitySave();
setFieldValuesBeforeSave();
}
private void setFieldValuesBeforeSave()
{
if (this.IsNew)
{
this.XxxAnAm = DateTime.Now;
this.XxxAnVon = HIS.Helper.UserLoggedOn.UserName;
this.XxxAnWs = HIS.Helper.UserLoggedOn.Workstation;
}
else
{
this.XxxGeAm = DateTime.Now;
this.XxxGeVon = HIS.Helper.UserLoggedOn.UserName;
this.XxxGeWs = HIS.Helper.UserLoggedOn.Workstation;
}
// here i wan't to add the users department to the current TblFirmenEntity.
JoinAbtZ();
}
private void JoinAbtZ()
{
if (this.TblAbtZ != null)
{
EntityCollection<TblAbtZEntity> abtz = this.TblAbtZ;
List<int> nfound = abtz.FindMatches(new PredicateExpression(TblAbtZFields.AbzAbtId == HIS.Helper.UserLoggedOn.DepartmentId));
if (nfound.Count == 0)
{
TblAbtZEntity newitem = new TblAbtZEntity();
newitem.AbzAbtId = HIS.Helper.UserLoggedOn.DepartmentId; // SESSION
TblAbtZ.Items.Add(newitem);
}
}
}
}