示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Ceen.Database.ColumnMapping"/> class.
 /// </summary>
 /// <param name="dialect">The database dialect.</param>
 /// <param name="property">The property to map.</param>
 public ColumnMapping(IDatabaseDialect dialect, PropertyInfo property)
 {
     Name         = dialect.GetName(property);
     IsPrimaryKey = property.GetCustomAttributes <PrimaryKeyAttribute>(true).Any();
     SqlType      = dialect.GetSqlColumnType(property);
     Property     = property;
 }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Ceen.Database.ColumnMapping"/> class.
        /// </summary>
        /// <param name="dialect">The database dialect.</param>
        /// <param name="member">The member to map.</param>
        /// <param name="memberType">The member type</param>
        private ColumnMapping(IDatabaseDialect dialect, MemberInfo member, Type memberType)
        {
            Member           = member ?? throw new ArgumentNullException(nameof(member));
            MemberType       = memberType;
            ColumnName       = dialect.GetName(member);
            QuotedColumnName = dialect.QuoteName(ColumnName);
            IsPrimaryKey     = member.GetCustomAttributes <PrimaryKeyAttribute>(true).Any();
            var sqlType = dialect.GetSqlColumnType(member);

            SqlType            = sqlType.Item1;
            AutoGenerateAction = sqlType.Item2;
            ValidationRules    = member.GetCustomAttributes <ValidationBaseAttribute>(true).ToArray();
        }