'UpdateDefination' Function with Update.Combine

Hello Fourm,

I paste example of my code below. I have a class with many save functions in it, one for each possible DTO type. I have been unable to find a way to merge them into one save type or specify the type as ‘t’ as the return so I for now I have many save Methods.

My Question, is it possible to somehow move the last four set functions to a function in my class to call from each method ? - I have tryed “update.combine” but as the type need to be specified in the ‘updatedefination’ I have been unable to get it to work. The dates are in a baseclass, so I also tryed specifying the baseclass, but then they cant be combined as they are different types, even though they are derived

My aim is to avoid repeating the same code for the dates in all the Object UPDATE Methods, in the builder defination

        ' // Set up the Updating Object Fields // 
        Dim Update = Builders(Of AboutUsServicePageDto).Update.Set(Function(d) d.Heading, ServicePage.Heading).
                                                               Set(Function(d) d.SubHeading, ServicePage.SubHeading).
                                                               Set(Function(d) d.ChangeDates.LastModifiedOn, Now()).
                                                               Set(Function(d) d.ChangeDates.LastModifiedBy, UserId).
                                                               SetOnInsert(Function(d) d.ChangeDates.CreatedOn, Now()).
                                                               SetOnInsert(Function(d) d.ChangeDates.CreatedBy, UserId) ' // 

        Try
            ' // Create the Collection Object //
            Dim DestinationCollection = Mongodb.GetCollection(Of AboutUsServicePageDto)(ServiceCollection)

            ' // Replace and return the document / Object after the Update as occurred //
            ServicePage = DestinationCollection.FindOneAndUpdate(IdTypeFilter, Update, New FindOneAndUpdateOptions(Of AboutUsServicePageDto, AboutUsServicePageDto) With
                                                                    {.IsUpsert = True, .ReturnDocument = ReturnDocument.After})

If possible I would like to do something like this

        ' // Set up the Updating Object Fields // 
        Dim Update = Builders(Of AboutUsServicePageDto).Update.Set(Function(d) d.Heading, ServicePage.Heading).
                                                               Set(Function(d) d.SubHeading, ServicePage.SubHeading).
                                                               Set({**something here**} 

I can set the dates in the MVC Model and then just save it as one line, but then I loose the ‘SetOnInsert’ Functionality