LLBLGenProDataSource2 EntityInserted not firing when LivePersistance=false

Posts   
 
    
yowl
User
Posts: 271
Joined: 11-Feb-2008
# Posted on: 06-Nov-2008 23:37:50   

One of these days I will find a genuine problem...

Why is it that the EntityInserted event is not fired when LivePersistance=false.

When LivePersistance=true: EntityInserting, then EntityInserted both fire as expected.

When LivePersistance=false: EntityInserting, then PerformWork fire. As it fires EntityInserting it must know that an entity is being inserted, so why does it not fire EntityInserted?

The help(Generated code - Databinding with ASP.NET 2.0, Adapter) says "In any case, the changed event is raised so the bound control(s) can refetch the data from the LLBLGenProDataSource2 control." Where is this changed event?

aspx code:

<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"> <ContentTemplate> <aspsmile etailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataSourceID="detailsDataSource" DefaultMode="Insert" CssClass="detailsview" GridLines="None"> <Fields> <asp:BoundField DataField="PageText" HeaderText="Text" SortExpression="PageText" /> <asp:CommandField ShowInsertButton="True" /> </Fields> </aspsmile etailsView> </ContentTemplate> </asp:UpdatePanel> <llblgenpro:LLBLGenProDataSource2 ID="detailsDataSource" runat="server" AdapterTypeName="em.DatabaseSpecific.DataAccessAdapter, emDBSpecific" DataContainerType="EntityCollection" EntityFactoryTypeName="em.FactoryClasses.PageEntityFactory, em" onentityinserted="detailsDataSource_EntityInserted" onentityinserting="detailsDataSource_EntityInserting" ThrowExceptionOnIllegalFieldInput="True" LivePersistence="True" onperformwork="detailsDataSource_PerformWork"> </llblgenpro:LLBLGenProDataSource2>

c# code

protected void detailsDataSource_EntityInserted(object sender, DataSourceActionEventArgs e)
{
}

protected void detailsDataSource_EntityInserting(object sender, CancelableDataSourceActionEventArgs e)
{
    var newPage = (PageEntity)e.InvolvedEntity;
    newPage.Order = 1;
}

protected void detailsDataSource_PerformWork(object sender, PerformWorkEventArgs2 e)
{
    e.Uow.Commit(new DataAccessAdapter());
}
Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 07-Nov-2008 10:20:04   

It's written in the description of these events in the Reference manual:

Event which is raised when LivePersistence is set to true

And that's because if LivePersistence is false, you already have to implement another events including PerformWork, in which you can check and act upon valid insertion of the entity, so you don't need another event to detect the insertion.

This is also valid for EntityUpdated and EntityDeleted.