Link Search Menu Expand Document

MySqlDbType


This attribute sets the MySqlParameter.MySqlDbType property value via a class property.

Compatible with both the MySql.Data and MySqlConnector packages.

Attribute

Example usage:

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

    [MySqlDbType(MySqlDbType.Text)]
    public string Name { get; set; }
}

Fluent Mapping

To configure via FluentMapper:

FluentMapper
    .Entity<Person>()
    .PropertyValueAttributes(e => e.Name, new MySqlDbTypeAttribute(MySqlDbType.Text))

Retrieval

Retrieve the attribute via PropertyValueAttributeCache:

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

Or via PropertyValueAttributeMapper:

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

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