Example #1
0
 /// <summary>
 /// create a new description how a business object double property (field) is persisted in a database;
 /// </summary>
 /// <param name="dbFieldName">a name of the database table field that the property value is persisted in</param>
 /// <param name="propName">a name of the the property that the value is managed by; match LightDataColumn name
 /// that is returned on business object field</param>
 /// /// <param name="valueGetter">a function to get a current value of the field</param>
 /// <param name="valueSetter">a function to set a current value of the field; the value is stored in the column
 /// with a name specified in the PropName property</param>
 /// <param name="persistenceType">a value indicating how a field value is persisted in the database</param>
 /// <param name="updateScope">an update scope that updates the property value in database.
 /// Update scopes are application defined enums that convert nicely to int, e.g. Financial, Depreciation etc.
 /// If no scope is assigned the field value is updated for every scope.</param>
 /// <param name="isInitializable">a value indicating whether the property value should be set (initialized)
 /// from the init query result</param>
 public OrmFieldMapDouble(string dbFieldName, string propName, Action <T, double?> valueSetter, Func <T, double?> valueGetter,
                          FieldPersistenceType persistenceType, int?updateScope = null, bool isInitializable = false)
     : base(dbFieldName, propName, persistenceType, updateScope, isInitializable)
 {
     if (persistenceType == FieldPersistenceType.Readonly)
     {
         ValueGetter = valueGetter;
     }
     else
     {
         ValueGetter = valueGetter ?? throw new ArgumentNullException(nameof(valueGetter));
     }
     ValueSetter = valueSetter ?? throw new ArgumentNullException(nameof(valueSetter));
 }
        /// <summary>
        /// create a new description how a business object property (field) is persisted in a database;
        /// </summary>
        /// <param name="dbFieldName">a name of the database table field that the property value is persisted in</param>
        /// <param name="propName">a name of the the property that the value is managed by; match LightDataColumn name
        /// that is returned on business object field</param>
        /// <param name="persistenceType">a value indicating how a field value is persisted in the database</param>
        /// <param name="updateScope">an update scope that updates the property value in database.
        /// Update scopes are application defined enums that convert nicely to int, e.g. Financial, Depreciation etc.
        /// If no scope is assigned the field value is updated for every scope.</param>
        /// <param name="isInitializable">a value indicating whether the property value should be set (initialized)
        /// from the init query result</param>
        protected OrmFieldMapBase(string dbFieldName, string propName, FieldPersistenceType persistenceType,
                                  int?updateScope = null, bool isInitializable = false)
        {
            if (dbFieldName.IsNullOrWhiteSpace())
            {
                new ArgumentNullException(nameof(dbFieldName));
            }
            if (propName.IsNullOrWhiteSpace())
            {
                new ArgumentNullException(nameof(propName));
            }

            DbFieldName     = dbFieldName.Trim();
            PropName        = propName.Trim();
            PersistenceType = persistenceType;
            UpdateScope     = updateScope;
            IsInitializable = isInitializable;
        }