Back to Devexpress

BaseObject Class

expressappframework-devexpress-dot-persistent-dot-baseimpl-dot-ef-5520c0c8.md

latest3.6 KB
Original Source

BaseObject Class

A base class for EF Core persistent classes.

Namespace : DevExpress.Persistent.BaseImpl.EF

Assembly : DevExpress.Persistent.BaseImpl.EFCore.v25.2.dll

NuGet Package : DevExpress.Persistent.BaseImpl.EFCore

Declaration

csharp
public abstract class BaseObject :
    IXafEntityObject,
    IObjectSpaceLink,
    IDeferredDeletion,
    IEFCoreBaseObject,
    IOptimisticLock
vb
Public MustInherit Class BaseObject
    Implements IXafEntityObject,
               IObjectSpaceLink,
               IDeferredDeletion,
               IEFCoreBaseObject,
               IOptimisticLock

Remarks

The key property of this class has the Guid type. Implements the IObjectSpaceLink and IXafEntityObject interfaces.

csharp
using DevExpress.Data.Filtering;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl.EF;

namespace YourSolutionName.Module.BusinessObjects;

[DefaultClassOptions]
public class MyPersistentClass : BaseObject {
    public virtual string Name { get; set; }
    public virtual bool IsNew { get; set; }
    public virtual ApplicationUser CreatedBy { get; set; }
    public virtual ApplicationUser LastModifiedBy { get; set; }
    ApplicationUser GetCurrentUser() {
        return ObjectSpace.FindObject<ApplicationUser>(CriteriaOperator.Parse("ID=CurrentUserId()"));
    }
    public override void OnCreated() {
        CreatedBy = GetCurrentUser();
        IsNew = true;
    }
    public override void OnLoaded() {
        IsNew = false;
    }
    public override void OnSaving() {
        if(ObjectSpace != null) {
            LastModifiedBy = GetCurrentUser();
        }
        IsNew = false;
    }
}

Implements

IXafEntityObject

IObjectSpaceLink

Inheritance

Show 12 items

Object BaseObject BaseObjectWithNotifyPropertyChanged

DashboardData

ModelDifference

ModelDifferenceAspect

Tenant

PermissionPolicyRoleBase

PermissionPolicyUser

ReportDataV2

MediaDataObject

PermissionPolicyRole

See Also

BaseObject Members

DevExpress.Persistent.BaseImpl.EF Namespace