示例#1
0
        public void Add(string key, object value)
        {
            if (value == null)
            {
                return;
            }

            if (value is string stringValue)
            {
                StringProperties.Add(key, stringValue);
            }
            else if (value is byte[] binaryValue)
            {
                BinaryProperties.Add(key, binaryValue);
            }
            else if (value is bool boolValue)
            {
                BooleanProperties.Add(key, boolValue);
            }
            else if (value is DateTimeOffset dateTimeOffsetValue)
            {
                DateTimeProperties.Add(key, dateTimeOffsetValue);
            }
            else if (value is DateTime dateTimeValue)
            {
                DateTimeProperties.Add(key, dateTimeValue);
            }
            else
            {
                IntegerProperties.Add(key, Convert.ToInt64(value));
            }
        }
        private static List <PropertyInfo> GetDateTimeProperties <TEntity>()
        {
            var key = typeof(TEntity);
            List <PropertyInfo> dateTimeProperties;

            if (!DateTimeProperties.TryGetValue(key, out dateTimeProperties))
            {
                dateTimeProperties = key.GetProperties().Where(p => p.PropertyType == typeof(DateTime)).ToList();
                DateTimeProperties.Add(key, dateTimeProperties);
            }
            return(dateTimeProperties);
        }