I have a existing parent-child relationship I am trying to map in Fluent Nhibernate:
[RatingCollection] --> [Rating]
Rating Collection has:
- ID (database generated ID)
- Code
- Name
Rating has:
- ID (database generated id)
- Rating Collection ID
- Code
- Name
I have been trying to figure out which permutation of HasMany makes sense here. What I have right now:
HasMany<Rating>(x => x.Ratings)
.WithTableName("Rating")
.KeyColumnNames.Add("RatingCollectionId")
.Component(c => { c.Map(x => x.Code);
c.Map(x => x.Name); );
It works from a CRUD perspective but because it's a bag it ends up deleting the rating contents any time I try to do a simple update / insert to the Ratings property. What I want is an indexed collection but not using the database generated ID (which is in the six digit range right now).
Any thoughts on how I could get a zero-based indexed collection (so I can go entity.Ratings[0].Name = "foo") which would allow me to modify the collection without deleting/reinserting it all when persisting?