Link Search Menu Expand Document


This attribute is used to set the value of the DbParameter.Size property via a class property.


Below a sample code on how to use this attribute.

public class Person
    public int Id { get; set; }

    public string Name { get; set; }

This works exactly the same as Map or the Table attribute of the System.ComponentModel.DataAnnotations.Schema namespace.

Fluent Mapping

Below is a sample code on how to use this attribute via FluentMapper.

    .PropertyValueAttributes(e => e.Name, new SizeAttribute(256));

The value from the database table/view is taking the precedence if present.


You can retrieve the attribute via PropertyValueAttributeCache.

var attribute = PropertyValueAttributeCache
    .Get<Person>(e => e.Name)?
    .FirstOrDefault(e => e.GetType() == typeof(SizeAttribute));

Or, via the PropertyValueAttributeMapper.

var attribute = PropertyValueAttributeMapper
    .Get<Person>(e => e.Name)?
    .FirstOrDefault(e => e.GetType() == typeof(SizeAttribute));

We strongly suggest to always use the PropertyValueAttributeCache to maximize the performance.