You can choose to don't save the collection ordered. //class mapped by field, you can do it by properties as well, I prefer this one. public class Person { private IList<Images> images;
IEnumerable<Images> ImagesOrderedBySomeCriteria //just to iterate, prevents to be modified in some ghost part of the application { get { return new ReadOnlyCollection(*OrderMyCollection*(this.images)); } } IEnumerable<Images> Images //just to iterate, prevents to be modified in some ghost part of the application { get {return new ReadOnlyCollection(this.images); } } } OrderMyCollection just order the collection into a new object that is returned and passed as readonly (you can avoid the ReadOnly if you want). On Fri, Jan 30, 2009 at 12:14 AM, reach4thelasers < kev.m.mul...@googlemail.com> wrote: > > Hi guys, > > I have a small problem. I've got a domain object Person, a person > has an IList of images which has an index to determine the position of > each element in the list. I want to take one element from the list > and put it at the start of the list, list[0]. > > I've tried the following: > > image oldfirst = Person.Images[0]; > > person.Images[0] = Person.Images[4]; > > person.Images[4] = oldfirst; > > personDao.Update(person); > personDao.CommitChanges; > > also tried something similar with person.Images.Remove(image) and > person.Images.insertat(0, images). > > But I'm getting a null reference expception because personID is null > and index is null in my images table. > > So, can anyone tell me: what is the best way to take an object from an > ordered list and put it at the beginning???? > > Any help with this would be so greatly appreciated. I am using 2.1.1 > though, so it could be a bug. > > Regards, > > Kevin. > > > > -- Dario Quintana http://darioquintana.com.ar --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---