Exemple #1
0
        private void AddParam(DbCommand cmd, PropertyValue propertyValue)
        {
            if (propertyValue.Raw is ValueBehavior)
            {
                switch (propertyValue.Raw as ValueBehavior?)
                {
                case ValueBehavior.Now:
                    cmd.AddParam(DateTime.Now);
                    break;

                case ValueBehavior.UtcNow:
                    cmd.AddParam(DateTime.UtcNow);
                    break;

                case ValueBehavior.Guid:
                    cmd.AddParam(Guid.NewGuid());
                    break;

                case ValueBehavior.CurrentUserId:
                    cmd.AddParam((int)_user.CurrentId());
                    break;

                case ValueBehavior.CurrentUserName:
                    cmd.AddParam(_user.CurrentUserName());
                    break;
                }
            }
            else
            {
                if (propertyValue.Property.TypeInfo.IsFileStoredInDb)
                {
                    cmd.AddParam(propertyValue.Raw, DbType.Binary);
                }
                else
                {
                    cmd.AddParam(propertyValue.Raw);
                }
            }
        }
Exemple #2
0
        private object GetDefaultValue(object value)
        {
            if (value is ValueBehavior)
            {
                switch ((ValueBehavior)value)
                {
                case ValueBehavior.CurrentUserId:
                    return(_user.CurrentId());

                case ValueBehavior.CurrentUserName:
                    return(_user.CurrentUserName());

                case ValueBehavior.Now:
                    return(_clock.Now);

                case ValueBehavior.UtcNow:
                    return(_clock.UtcNow);
                }
            }

            return(value);
        }