I have created a Silverlight application with CSLA. I want to assign default values to some of the BusinessBase class's properties, which are not bound to the UserControls.
eg: 1] SysDate - The current datetime should be assigned to it.
2] UserId - The current user's id should be assigned to it.
These fields are not bound to UI.
So, where should I assign these values in BusinessBase class?
Or what is the best practice for handling such type of issue?
For CSLA 4.5 this is how I do it:
/// Loads default values for the <see cref="Doc"/> object properties.
protected override void DataPortal_Create()
LoadProperty(DocDateProperty, new SmartDate(DateTime.Today));
Thanks..I tried your suggestion & it worked..
Why do you need them in the BO?
If you only use it for tracking of last changed/changed by in a database you do not need these properties in your BO.
Use Csla.ApplicationContext.User.Name to get the userid and DateTime,.Now() to get the timestamp in your DataPortal_XYZ methods.
Thanks for reply..
There are some dependent properties which need to be validated on UserId & SysDate.
So I am trying to initialize in BO.
If any other way, please suggest.
In this case you must initialize the values in DataPortal_Create and DataPortal_Fetch.
Copyright (c) Marimer LLC