Persistable collection hash codes
Please see the objects below. What I need to do is query the entity
framework for instances of MyObject that contain a specific collection of
Option. For instance, I want all MyObject where the Options collection
contains Option Id = 1 & Options Id = 5 and no other options.
public class MyObject
{
public int Id { get; set; }
//... More Properties
public IEnumerable<Option> Options { get; }
}
public class Option
{
public int Id { get; set; }
public string Name { get; set; }
}
I was thinking of trying to implement some sort of option hash and
persisting it. Then, my query would be "where MyObject.OptionHash ==
[HASH]". As far as I can tell, typical hash algorithms cannot generate a
guaranteed unique hash. Any input or suggestions would be appreciated.
No comments:
Post a Comment