Hi, I have looked in the documentation and also in the forum but didn't find anything. So is it even possible with DO to set some default values on fields like:

[Field (DefaultValue(typeof(int), 100))] public int Number {get;set;}

thanks, David

This thread was imported from our support forum. The original discussion may contain more detailed answer. Original topic by david_csharp.

asked Jul 05 '10 at 15:00

Editor's gravatar image

Editor
46156156157


One Answer:

There is really no way to do this - at least, currently. Only "default defaults" are supported. Partially, this is because of schema upgrade layer - it's much easier to deal with defaults there.

But you can:

  • Set default in constructor (in particular, relying on reflection or any other "defaults provider" you can invent)

  • Manually update newly created columns with non-standard defaults on upgrade using UpgradeHander, if this is necessary.

answered Jul 06 '10 at 09:02

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412

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