google-code-export / dataobjectsdotnet

Automatically exported from code.google.com/p/dataobjectsdotnet
0 stars 0 forks source link

Refactor Orm-level upgrade hints API - we must use fluent model builder there #857

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'd prefer to have the following API there:

var upgradeModel = UpgradeModel
  .Target(m => m
    .Type<User>(t => {
      t.OldName = "Account",
      t.Field(t => t.Password, f => {
        f.OldName = "EncryptedPassword";
        f.ChangeType = true;
        f.Recycled = екгу;
      });
      t.Index("IX_Name, i => {
        i.CreateAfterUpgrade = true;
      });
    })
    .Type<...>(...);
  .Source(m =>
    .Type("MyModel.Role", t => {
      t.Removed = true;
    });
  });

Original issue reported on code.google.com by alex.yakunin on 27 Nov 2010 at 1:04

GoogleCodeExporter commented 9 years ago
Forgot to mention:

1) Any node here - .Target, .Type, .Field and so on, creates a new node of 
corresponding type there, or uses an existing one, if it is available.

2) Agreements on builders:

upgradeModel.TargetModel - target upgrade model
upgradeModel.Target(
  Func<TargetModelBuilder, TargetModelBuilder> 
  targetModelBuilder) - its builder. Being executed, it 
  updates TargetModel as it is described.

TargetType.Fields - fields collection of a target type
TargetType.Field(Func<TargetFieldBuilder, TargetFieldBuilder> 
  targetFieldBuilder) - its builder.

3) It isn't necessary to do the same with hints from 
Xtensive.Modelling,Comparison.Hints namespace. They're internal, so
normally people won't even know about them.

Original comment by alex.yakunin on 27 Nov 2010 at 1:29