Field is link to some entity. I have some logic about filling it.

Is there any upgrade handlers to: 1. create field (nullable) 2. fill it with my custom logic 3. make it not nullbale

asked Feb 03 '11 at 04:04

pil0t's gravatar image


One Answer:

Yes: currently you must use [Field(NullableOnUpgrade = true)] property to ensure this.

Note: this part of API is preliminary - probably, we'll convert this to hint later.

If this property is used, DO considers the field is nullable until the final stage of upgrade. So e.g. you can use the following code in upgrade handlers:

public override void OnUpgrade()
    var session = Session.Demand();
    var none = new Person {Name = "None"}; // Replacement for former NULL value
    none.Friend = none;

    ( from p in Session.Demand().Query.All<Person>()
      where p.Friend==null
      select p
    ).ForEach(p => { p.Friend = none; });

answered Feb 03 '11 at 23:42

Alex%20Yakunin's gravatar image

Alex Yakunin

edited Feb 03 '11 at 23:43

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA