Hi,
I'm writing an application using Entity Framework 6 code first.
I have a relationship where the order of the elements must be modifiable by the user and must always be retrieved in the same way. When working with NHibernate, one can configure the "type" of relationship when doing a "On to many" and select whether it's a "Set", "Bag", "List", etc.
Is there something similar in EF?
As an example, let's say I have this kind of classes:
How do I tell EF that the order of the "ReadCommands" is important and should be saved?
I did a small test and when I do
And then save the
Thanks.
I'm writing an application using Entity Framework 6 code first.
I have a relationship where the order of the elements must be modifiable by the user and must always be retrieved in the same way. When working with NHibernate, one can configure the "type" of relationship when doing a "On to many" and select whether it's a "Set", "Bag", "List", etc.
Is there something similar in EF?
As an example, let's say I have this kind of classes:
publicclass ReadProcess { publicint Id {get; set;} publicstring Name {get; set;} public ICollection<ReadCommand> ReadCommands {get; set;} } publicclass Command : ICommand { publicint Id {get; set;} publicstring FileName {get; set;} publicvoid Execute() { ... } }
I did a small test and when I do
MyReadProcess.ReadCommands.Insert(0, testCommand);
MyReadProcess
, the testCommand
is correctly saved, but not keeping the order.Thanks.