Dreamine.Database.Core 1.0.1
Dreamine.Database.Core 데이터베이스 기능과 관련 API를 제공합니다.
로딩중...
검색중...
일치하는것 없음
DatabasePropertyMap.cs
이 파일의 문서화 페이지로 가기
1using System.Reflection;
2using Dreamine.Database.Abstractions.Mapping;
3
5
14public sealed class DatabasePropertyMap
15{
56 private DatabasePropertyMap(PropertyInfo property, string columnName, bool isKey, bool isGenerated)
57 {
58 Property = property;
59 ColumnName = columnName;
60 IsKey = isKey;
61 IsGenerated = isGenerated;
62 }
63
72 public PropertyInfo Property { get; }
73
82 public string ColumnName { get; }
83
92 public Type PropertyType => Nullable.GetUnderlyingType(Property.PropertyType) ?? Property.PropertyType;
93
102 public bool IsKey { get; }
103
112 public bool IsGenerated { get; }
113
146 public static DatabasePropertyMap Create(PropertyInfo property)
147 {
148 ArgumentNullException.ThrowIfNull(property);
149
150 var columnName = property.GetCustomAttribute<DatabaseColumnAttribute>()?.Name ?? property.Name;
151 var isKey = property.GetCustomAttribute<DatabaseKeyAttribute>() is not null ||
152 string.Equals(property.Name, "Id", StringComparison.OrdinalIgnoreCase);
153 var isGenerated = property.GetCustomAttribute<DatabaseGeneratedAttribute>() is not null;
154
155 return new DatabasePropertyMap(property, columnName, isKey, isGenerated);
156 }
157}
static DatabasePropertyMap Create(PropertyInfo property)
DatabasePropertyMap(PropertyInfo property, string columnName, bool isKey, bool isGenerated)