I have the following tables with a one to many relationship one list:
List
----
Id
Name
Type etc...
ListItem
----
Id
ListId
Label etc..
I have the following classes:
public class List
{
public Guid Id{get;set;}
public IList<ListItem> {get;set;}
}
public class ListItem
{
public Guid Id{get;set;}
public string Label {get;set;}
}
I am trying to figure out an efficient method to map these. At first I modeled ListItem as its own entity but I noticed nHibernate was inserting the list item then going back and updating the id. Since a ListItem will only ever exist on a single list this I didn't see a need to make it its own entity.
I have tried to model this as an idBag but the Id property on my object isn't getting populated. Seems like if I want to use an idBag I have to modify my data store to store an additional CollectionId, which I'm not a fan of.
I am willing to change my data store or model here.