This project has moved and is read-only. For the latest updates, please go here.

Supporting field re-ordering

Jun 14, 2011 at 9:01 AM

I understand that I will have to do some work to upgrade existing Sterling databases if I change my domain model in a future version.  But I can think of one potential small domain code change that Sterling could handle: field re-ordering.  Suppose I have this class:

public class MyClass {

   public string First {get; set;}

   public string Second {get; set;}


Now imagine that in the next release a developer swaps the declarations of First and Second in the above code.  They might not realize that this will break Sterling.  I think I can see a way to prevent it from causing problems, by adding a couple of .OrderBy()s in SerializationHelper._CacheProperties.  This is what I have in mind: 

var fields = from f in type.GetFields().OrderBy(f => f.Name)


var properties = from p intype.GetProperties().OrderBy(p => p.Name)

Now the declaration order won't matter.  Of course, adding, renaming or deleting fields will still cause problems. 

Does this sounds like a good idea?  Thanks in advance for any advice you can offer.