Implement custom code in Save

Posts   
 
    
dazedorconfused avatar
Posts: 89
Joined: 06-Apr-2006
# Posted on: 15-Jul-2018 04:11:36   

If I want to implement custom code in the entity's Save() method (in SelfServicing using LLBLGen Runtime Framework) I would think I could do it like so:


public partial class SiteEntity
    {
        public override bool Save()
        {
            if (this.IsNew)
                this.CreateDate = DateTime.Now;
            this.LastUpdateDate = DateTime.Now;
            return base.Save();
        }
    }

However, this code will not compile due to 'SiteEntity.Save()' cannot override inherited member 'EntityBase.Save()' because it is not marked virtual, abstract, or override

I am targeting .Net Standard if that makes any difference and I am using LLBLGen 5.4.2 with the hotfix applied.

Is this no longer the right way to do this?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 16-Jul-2018 09:21:26   

Override InsertEntity() and UpdateEntity() (set the values you want, then call the base method) simple_smile

Frans Bouma | Lead developer LLBLGen Pro
dazedorconfused avatar
Posts: 89
Joined: 06-Apr-2006
# Posted on: 16-Jul-2018 18:36:27   

That was it exactly. Thank you and sorry if this was in the docs and I missed it.

dazedorconfused avatar
Posts: 89
Joined: 06-Apr-2006
# Posted on: 15-Mar-2020 22:47:23   

This is now deprecated... what should I use in it's place?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 16-Mar-2020 05:45:16   

Are you talking about UpdateEntity method?

Quoting the docs: The following breaking changes have been in LLBLGen Pro Runtime Framework v5.6.

(SelfServicing) EntityBase.UpdateEntity() is now marked as obsolete with error severity, as the method is never called/used. You should override EntityBase.UpdateEntity(IPredicate) instead.

Ref: https://www.llblgen.com/Documentation/5.6/LLBLGen%20Pro%20RTF/migratingcode.htm

David Elizondo | LLBLGen Support Team