Or List<KeyValuePair<int,Object>>, or a dictionary.
Depending on Entity Framework and PostgreSQL database we are trying to model a part of data which basically consists of a list of references to an object called OtherObject which has an ID. The data we try to store is a MyObject and consists of an Id, and two lists (with a maximum length of 12) of one or more references to the OtherObject and the amount of OtherObjects. So we want to store data (in for example a separate table and columns) which correlates to this:
FirstPattern:
OtherObject with ID 1, 10 times
OtherObject with ID 4, 12 times
SecondPattern:
OtherObject with ID 2, 2 times
OtherObject with ID 3, 4 times
OtherObject with ID 4, 11 times
To do this we thought an ICollection of KeyValuePairs would be appropriate. That way we have a list that has a value (an amount) for each Key (the OtherObject).
The model now basically looks as follows:
public class MyObject
{
    public int Id { get; set; }
    public IDictionary<OtherObject, int> FirstPattern { get; set; }
    public IDictionary<OtherObject, int> SecondPattern { get; set; }
}
How can we possible store this ICollection of KeyValuePairs in the database?
Is there a (better) way?
 
    