This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Method Call: GetOldValue

Hello,

i have following Code with the method call: "GetOldValue" that is working fine in v6, but not in v7:

 

Dim f as ISqlFormatter = Connection.SqlFormatter

Dim histPerson as New VI.DB.History.ColumnHistory(Base, "UID_PersonHead", Connection.LocalNow.AddDays(-100))

 if histPerson.Changes.Count > 0

      values("UID_PersonHeadOld") = histPerson.Changes.Last.GetOldValue("UID_PersonHead").ToString()

End if

I receive the Errormessage: "GetOldValue" is no member of "VI.DB.History.IObjectChangeInfo"

How is the function now properly called in v7?

Thanks Fatih

Parents
  • Hi Fatih,

    the code for 7.x should look like this.

    Dim f As ISqlFormatter = Connection.SqlFormatter
    Dim histPerson As New VI.DB.History.ColumnHistory(Base, "UID_PersonHead", Connection.LocalNow.AddDays(-100))
    values("UID_PersonHeadOld") = histPerson.Changes.Last.Changes _
        .Where(Function(c) String.Equals(c.Columnname, "UID_PersonHead", StringComparison.OrdinalIgnoreCase)) _
        .Select(Function(c) DbVal.ConvertTo(Of String)(c.OldValue)) _
        .FirstOrDefault()
        

    But please allow me the question to ask what you want to achieve with that piece of code? Do you want to get the old value of the last change to UID_PersonHead?

    In that case, as the history will always be walked backwards in time, you may want to use First instead of Last in the code.

    HtH

Reply
  • Hi Fatih,

    the code for 7.x should look like this.

    Dim f As ISqlFormatter = Connection.SqlFormatter
    Dim histPerson As New VI.DB.History.ColumnHistory(Base, "UID_PersonHead", Connection.LocalNow.AddDays(-100))
    values("UID_PersonHeadOld") = histPerson.Changes.Last.Changes _
        .Where(Function(c) String.Equals(c.Columnname, "UID_PersonHead", StringComparison.OrdinalIgnoreCase)) _
        .Select(Function(c) DbVal.ConvertTo(Of String)(c.OldValue)) _
        .FirstOrDefault()
        

    But please allow me the question to ask what you want to achieve with that piece of code? Do you want to get the old value of the last change to UID_PersonHead?

    In that case, as the history will always be walked backwards in time, you may want to use First instead of Last in the code.

    HtH

Children
No Data