/// <summary> /// Constructor /// </summary> /// <param name="expression">Expression used to point to the property</param> /// <param name="mapping">Mapping the StringID is added to</param> protected IDPropertyBase(Expression <Func <TClassType, TDataType> > expression, IMapping mapping) { if (expression is null) { throw new ArgumentNullException(nameof(expression)); } if (mapping is null) { throw new ArgumentNullException(nameof(mapping)); } Name = expression.PropertyName(); ColumnName = mapping.Prefix + Name + mapping.Suffix; CompiledExpression = expression.Compile(); Constraints = new List <string>(); ComputedColumnSpecification = string.Empty; DefaultValue = DefaultDefaultValue; Expression = expression; SetAction = Expression.PropertySetter <TClassType, TDataType>()?.Compile() ?? DefaultSetAction; InternalFieldName = $"_{Name}Derived"; PropertyType = typeof(TDataType); MaxLength = PropertyType == typeof(string) ? 100 : 0; ParentMapping = mapping; TypeName = PropertyType.GetName(); Index = true; Unique = true; _HashCode = Name.GetHashCode(StringComparison.Ordinal) * ParentMapping.GetHashCode() % int.MaxValue; _ToString = $"{PropertyType.GetName()} {ParentMapping}.{Name}"; }