This project is read-only.

HashSet Problem!!!!

Dec 19, 2014 at 8:15 AM
Edited Jan 13, 2015 at 8:26 AM
Dear All,

I've got problems when I store a HashSet in db, after loading back in memory I'm no more able to remove items from hashset, the hash code of items is changed even if no modifications are made on items..... My only stupid workaround is to regenerate the hashset copy all elements to a new one. In the follwing there is a code sample that make the same behaviour.
    public class MyClass
        public string Name="Name";
        public int Index =1;
        public MyClass (string name, int index)
            Name = name;
            Index = index;
    public void TestDatabase()

        HashSet<MyClass> list = new HashSet<MyClass>();
        list.Add(new MyClass("First",1));
        list.Add(new MyClass("Second",2));
        int code1, code2, code3;
        using (var odb = OdbFactory.Open("c:\\Prova.db"))
            code1 = list.FirstOrDefault().GetHashCode();
            code2 = list.FirstOrDefault().GetHashCode();
            // code1 = code2 OK
        HashSet<MyClass> list2;
        using (var odb = OdbFactory.Open("c:\\Prova.db"))

            var result = odb.QueryAndExecute<HashSet<MyClass>>();
            list2 = result.FirstOrDefault();
            code3 = list2.FirstOrDefault().GetHashCode();
            // code3 != code2 !!!!!!!!!!!
        // Try to remove First item in list

        bool success = list2.Remove(list2.First());
        // success is FALSE!!!!!
Is there some configuration or option I've to activate to made odb deserialize hashset correctly?

Many thanks for reply and Merry Christmas!!!

Feb 4, 2015 at 10:55 AM
Is There Anyone that could reply to my question?