Show / Hide Table of Contents

Interface INestedPersist

Interface to be implemented by objects that are to take place in a nested persist (INSERT/UPDATE to the database).

Namespace: SuperOffice.Data
Assembly: SoDataBase.dll
Syntax
public interface INestedPersist
Remarks

This interface support rather complex save operations. Through a 6-step process a set of related objects can take part of a save operation. All objects taking part of the nested save process should implement this interface.

    In addition to exposing the 6-step save process, this interface also expose a method for the save process itself, and a property to check if the object is dirty (in need of an SQL UPDATE).

    Properties

    IsDeleted

    Gets a value indicating whether this instance is deleted.

    Declaration
    bool IsDeleted { get; }
    Property Value
    Type Description
    bool

    true if this instance is deleted; otherwise, false.

    Remarks

    This interface support rather complex save operations. Through a 6-step process a set of related objects can take part of a save operation. All objects taking part of the nested save process should implement this interface.

      In addition to exposing the 6-step save process, this interface also expose a method for the save process itself, and a property to check if the object is dirty (in need of an SQL UPDATE).

      IsDirty

      Is the object dirty?

      Declaration
      bool IsDirty { get; }
      Property Value
      Type Description
      bool

      true if dirty; otherwise, false.

      Remarks

      This interface support rather complex save operations. Through a 6-step process a set of related objects can take part of a save operation. All objects taking part of the nested save process should implement this interface.

        In addition to exposing the 6-step save process, this interface also expose a method for the save process itself, and a property to check if the object is dirty (in need of an SQL UPDATE).

        IsMarkedForDelete

        Gets or sets a value indicating whether this instance is marked for delete.

        Declaration
        bool IsMarkedForDelete { get; set; }
        Property Value
        Type Description
        bool

        true if this instance is marked for delete; otherwise, false.

        Remarks

        This interface support rather complex save operations. Through a 6-step process a set of related objects can take part of a save operation. All objects taking part of the nested save process should implement this interface.

          In addition to exposing the 6-step save process, this interface also expose a method for the save process itself, and a property to check if the object is dirty (in need of an SQL UPDATE).

          IsSaving

          Is the nested persist in a saving state, hence disable Sentry when reading id's

          Declaration
          bool IsSaving { get; }
          Property Value
          Type Description
          bool

          true if this instance is saving; otherwise, false.

          Remarks

          This interface support rather complex save operations. Through a 6-step process a set of related objects can take part of a save operation. All objects taking part of the nested save process should implement this interface.

            In addition to exposing the 6-step save process, this interface also expose a method for the save process itself, and a property to check if the object is dirty (in need of an SQL UPDATE).

            Methods

            OnIdUpdateAsync()

            Update related objects with correct id's to make sure that relations are consistent before saving to the database.

            Declaration
            Task OnIdUpdateAsync()
            Returns
            Type Description
            Task
            Remarks

            This interface support rather complex save operations. Through a 6-step process a set of related objects can take part of a save operation. All objects taking part of the nested save process should implement this interface.

              In addition to exposing the 6-step save process, this interface also expose a method for the save process itself, and a property to check if the object is dirty (in need of an SQL UPDATE).

              OnPreIdUpdateAsync()

              Allow for "fake id's" to be forced upon related objects.

              Declaration
              Task OnPreIdUpdateAsync()
              Returns
              Type Description
              Task
              Remarks

              In order to figure out which objects taking part of the nested save operation that actually needs to be saved, this method allows for "fake id's" to be forced upon related objects. Upon receiving the "fake id", the objects receiving such an id can determine if they needs to be persisted (e.g. saved) to the database. However, the fake id's forced upon related objects must be set to correct id's in the OnIdUpdate method taking place later in the save operation.

              OnPrimaryKeyRequestAsync(PKContainer)

              Allow the object to add itself to a collection of requests for primary keys.

              Declaration
              Task OnPrimaryKeyRequestAsync(PKContainer pkContainer)
              Parameters
              Type Name Description
              PKContainer pkContainer

              Collection of objects getting a primary key.

              Returns
              Type Description
              Task
              Remarks

              When implementing this method, add yourself to the collection if you need a new primary key.

              OnPrimaryKeyUpdateAsync(PKContainer)

              Update primary key.

              Declaration
              Task OnPrimaryKeyUpdateAsync(PKContainer pkContainer)
              Parameters
              Type Name Description
              PKContainer pkContainer

              Collection of objects getting a primary key.

              Returns
              Type Description
              Task
              Remarks

              This interface support rather complex save operations. Through a 6-step process a set of related objects can take part of a save operation. All objects taking part of the nested save process should implement this interface.

                In addition to exposing the 6-step save process, this interface also expose a method for the save process itself, and a property to check if the object is dirty (in need of an SQL UPDATE).

                OnSaveAsync(BatchSave)

                Add the object to the collection of objects that are to be saved within the transaction.

                Declaration
                Task OnSaveAsync(BatchSave batchSave)
                Parameters
                Type Name Description
                BatchSave batchSave

                An object holding all the objects that needs to be persisted.

                Returns
                Type Description
                Task
                Remarks

                This interface support rather complex save operations. Through a 6-step process a set of related objects can take part of a save operation. All objects taking part of the nested save process should implement this interface.

                  In addition to exposing the 6-step save process, this interface also expose a method for the save process itself, and a property to check if the object is dirty (in need of an SQL UPDATE).

                  OnSavedAsync(bool)

                  Called after the save operation has completed. A boolean value is passed to notify whether or not the save operation succeeded. The complete save operation is rolled back if Save operation failed.

                  Declaration
                  Task OnSavedAsync(bool bSucceeded)
                  Parameters
                  Type Name Description
                  bool bSucceeded

                  True if the save operation succeeded and false if the save operation failed and rolled back.

                  Returns
                  Type Description
                  Task
                  Remarks

                  This interface support rather complex save operations. Through a 6-step process a set of related objects can take part of a save operation. All objects taking part of the nested save process should implement this interface.

                    In addition to exposing the 6-step save process, this interface also expose a method for the save process itself, and a property to check if the object is dirty (in need of an SQL UPDATE).

                    SaveAsync()

                    Save all the contained objects to the database.

                    Declaration
                    Task SaveAsync()
                    Returns
                    Type Description
                    Task
                    Remarks
                    <p>
                    

                    Save contained objects to the database:

                      SetSaveOwner(INestedPersist)

                      Force the save operation to be handled by someone else.

                      Declaration
                      void SetSaveOwner(INestedPersist saveOwner)
                      Parameters
                      Type Name Description
                      INestedPersist saveOwner

                      The object to handle the save operation.

                      Remarks

                      This interface support rather complex save operations. Through a 6-step process a set of related objects can take part of a save operation. All objects taking part of the nested save process should implement this interface.

                        In addition to exposing the 6-step save process, this interface also expose a method for the save process itself, and a property to check if the object is dirty (in need of an SQL UPDATE).

                        Events

                        OnElementIdUpdate

                        Interface to be implemented by objects that are to take place in a nested persist (INSERT/UPDATE to the database).

                        Declaration
                        event OnIdUpdate OnElementIdUpdate
                        Event Type
                        Type Description
                        OnIdUpdate
                        Remarks

                        This interface support rather complex save operations. Through a 6-step process a set of related objects can take part of a save operation. All objects taking part of the nested save process should implement this interface.

                          In addition to exposing the 6-step save process, this interface also expose a method for the save process itself, and a property to check if the object is dirty (in need of an SQL UPDATE).

                          Extension Methods

                          EnumUtil.MapEnums<From, To>(From)
                          Converters.MapEnums<From, To>(From)
                          © SuperOffice. All rights reserved.
                          SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top