InsertEntity and UpdateEntity not being hit

Posts   
 
    
Posts: 10
Joined: 11-Aug-2017
# Posted on: 23-Oct-2018 13:16:14   

We have a project running: LLBLGen 2.6 SelfServicing (Two Classes) SQL Server 2012

I tried updating it to: LLBLGen 5.4.3 from Nuget. SelfServicing (Two Classes) SQL Server 2012

It seemed to be running fine but then I noticed that in the LLBLGen 5.4 version. The InsertEntity and UpdateEntity don't get called at all.

I debugged through the code and it hit these breakpoints (in this order):


public override bool Save(IPredicate updateRestriction, bool recurse)

protected override void OnSave()

protected override void OnTransactionCommit()

but never goes into:


protected override bool InsertEntity()

protected override bool UpdateEntity()

The entity is being saved using:


try
{
    request.Save(true);
}
catch (Exception e)
{

}

There are some null value checks, property changes, etc that would always run whenever this entity gets saved. It sometimes gets saved as part of a collection and not on it's own and that is why it was put in the InsertEntity and UpdateEntity and not in the Save.

Any idea why the InsertEntity and UpdateEntity would not be called?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 23-Oct-2018 15:51:13   

You did generate code for 5.4? You can't just update the runtimes with a newer build, your generated code has to be updated as well.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 10
Joined: 11-Aug-2017
# Posted on: 23-Oct-2018 16:47:28   

Hi Otis,

Yip I did. I used 02-October-2018 5.4.3 installer. Used the v2.x to v5.x migration template as well (in the beginning).

It is a solution with 25 projects (Windows, Web and new Web API) and everything seems to work fine, just that issue.

I reverted it to 5.4.2 but the same thing happens.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 24-Oct-2018 08:22:25   

I can't reproduce your behavior with the same stack. We need more information to reproduce it, and see whether it's something that need a fix or not.

  • Does this happen with all entities or just a specific one?
  • Does this happen always or just in certain situations?
  • Where exactly is the InsertEntity override? (The entity base clase, the entity child class, commonEntityBase, etc).
  • Can you reproduce it in a project from scratch?
David Elizondo | LLBLGen Support Team
Posts: 10
Joined: 11-Aug-2017
# Posted on: 24-Oct-2018 09:14:04   

My most humble apologies about the InsertEntity(), it is actually being hit. Brain fart.

BUT, after looking around at the LLBLGen source, from what I can see, the UpdateEntity() will never be hit in v5.4. Only UpdateEntity(IPredicate updateRestriction) will be hit.

Here is a snippet from PersistQueue in v2.6:


if (additionalUpdateFilter == null)
{
    flag3 = entityBase2.CallUpdateEntity();
}
else
{
    flag3 = entityBase2.CallUpdateEntity(additionalUpdateFilter);
}

Here is a snippet from PersistQueue in v5.4:


wasSuccesful = insertActions ? entityToSave.InsertEntity() : entityToSave.UpdateEntity(updateRestriction);

So I need to go change all the old UpdateEntity() overrides to use the UpdateEntity(IPredicate updateRestriction) override instead.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 24-Oct-2018 15:51:36   

Hmm, you're right!

It's not marked as dead code by the analyzers as it's a virtual method, but indeed the method itself isn't used by the framework.

We'll mark it as obsolete (warning) in a next version.

Frans Bouma | Lead developer LLBLGen Pro