none
Hash codes to detect change RRS feed

  • Question

  • I would like to create a hashcode to store in a database, so later I will know if a different object representing the same set of conditions, has changed.

    This object has five integers, one string and one bool.

     The flow is this.

    1.  Initialize object

    2.  Test against DB value

    3.  Take action if there is a change as indicated by the DB value.

    4. repeat with next object.

    I would then like to test against  hash codes in the database and know if I need to take action, because something has changed.

    I am looking for links that explain how to use hash codes in this sort of situation,.

    thanks 



    • Edited by danielsn Thursday, April 26, 2018 11:05 PM
    Thursday, April 26, 2018 10:33 PM

Answers

All replies

  • Please rephrase your question.. cause it's not really clear what you want. Do you want to create an appropriate hash or know how to proceed in such an situation.
    Friday, April 27, 2018 12:01 AM
  • Hello danielsn,

    >>I am looking for links that explain how to use hash codes in this sort of situation.

    Maybe you could take reference with the MSDN document and also you could override custom GetHashcode method and compare value between them.

    https://msdn.microsoft.com/en-us/library/system.object.gethashcode%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396

    Best Regards,

    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by danielsn Friday, April 27, 2018 2:15 PM
    Friday, April 27, 2018 6:10 AM
    Moderator
  • It turns out I have to write a custom unique value, if I want to persist it, as Microsoft documentation says not to persist hash values.  (Though larger ones like "SHA-1" might be an exception.)
    Friday, April 27, 2018 3:44 PM