コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SimpleColumnMapping{TEntity}" /> class.
        /// </summary>
        /// <param name="property">The property that the mapping is for.</param>
        /// <param name="columnName">Name of the column in the table.</param>
        /// <param name="converter">Used of the column value is not of the same type as the property.</param>
        public SimpleColumnMapping(Expression <Func <TEntity, object> > property, string columnName,
                                   IColumnConverter converter)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }
            if (columnName == null)
            {
                throw new ArgumentNullException("columnName");
            }

            _columnName = columnName;
            _converter  = converter;
            var member = property.GetMemberInfo();

            _propertyInfo = (PropertyInfo)member.Member;
        }
コード例 #2
0
ファイル: SimpleMapper.cs プロジェクト: taiab/Griffin.Data
        /// <summary>
        /// Add a column mapping
        /// </summary>
        /// <param name="property">Property to map</param>
        /// <param name="columnName">Column in the table</param>
        /// <param name="converter">Converter (converts from the column type to the property type)</param>
        public void Add(Expression <Func <TEntity, object> > property, string columnName, IColumnConverter converter)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }
            if (columnName == null)
            {
                throw new ArgumentNullException("columnName");
            }
            if (converter == null)
            {
                throw new ArgumentNullException("converter");
            }

            var mapping = new SimpleColumnMapping <TEntity>(property, columnName, converter);

            _mappings.Add(mapping);
        }