internal CSRelation(CSSchema schema, RelationAttribute att) { _schema = schema; Attribute = att; }
internal CSSchemaField(PropertyInfo propInfo, CSSchema schema) { _propertyInfo = propInfo; _schema = schema; _fieldType = _propertyInfo.PropertyType; _realType = _fieldType.Inspector().RealType; RelationAttribute attRelation = propInfo.GetCustomAttribute <RelationAttribute>(true); _prefetch = propInfo.IsDefined(typeof(PrefetchAttribute), true); if (attRelation != null) { _relation = new CSRelation(schema, attRelation); return; } _lazy = propInfo.IsDefined(typeof(LazyAttribute), true); _noCreate = propInfo.IsDefined(typeof(NoCreateAttribute), true); _trim = propInfo.IsDefined(typeof(TrimAttribute), true); _optimisticLock = propInfo.IsDefined(typeof(OptimisticLockAttribute), true); _clientGenerated = propInfo.IsDefined(typeof(ClientGeneratedAttribute), true); _serverGenerated = propInfo.IsDefined(typeof(ServerGeneratedAttribute), true); _notMapped = propInfo.IsDefined(typeof(NotMappedAttribute), true); var mapToAttribute = propInfo.GetCustomAttribute <MapToAttribute>(true); var nullValueAttribute = propInfo.GetCustomAttribute <NullValueAttribute>(true); var identityAttribute = propInfo.GetCustomAttribute <IdentityAttribute>(true); if (!_notMapped) { if (CSConfig.ColumnMappingOverrideMap.ContainsValue(propInfo.DeclaringType.Name + ":" + propInfo.Name)) { _mappedColumn = schema.Columns[ CSConfig.ColumnMappingOverrideMap[propInfo.DeclaringType.Name + ":" + propInfo.Name]]; } else if (mapToAttribute != null) { _mappedColumn = schema.Columns[mapToAttribute.Name]; } else { _mappedColumn = schema.Columns[propInfo.Name]; } if (_mappedColumn != null) { _mappedColumn.MappedField = this; } } var sequenceAttribute = propInfo.GetCustomAttribute <SequenceAttribute>(true); if (sequenceAttribute != null && _schema.DB.SupportsSequences) { _sequenceName = sequenceAttribute.SequenceName; if (_mappedColumn != null && sequenceAttribute.Identity) { _mappedColumn.Identity = true; _schema.IdentityColumn = _mappedColumn; } } if (identityAttribute != null) { if (_mappedColumn != null) { _mappedColumn.Identity = true; _schema.IdentityColumn = _mappedColumn; } } if (nullValueAttribute != null) { _nullValue = nullValueAttribute.NullValue; } else { Type fieldType = FieldType; if (fieldType == typeof(string)) { _nullValue = String.Empty; } else if (fieldType.GetTypeInfo().IsValueType) { _nullValue = Activator.CreateInstance(fieldType); } } if (_mappedColumn != null && _mappedColumn.ReadOnly) { if (_propertyInfo.CanWrite) { throw new CSException("Property [" + Name + "] for class [" + _schema.ClassType.Name + "] should be read-only"); } } }