Char Properties

This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.

This topic demonstrates how to describe char properties in backend independent manner. The Fluent Mapping API exposes the following methods that allow you to map char properties in an abstract way:

  • IsUnicode - specifies that the char property should be mapped to a unicode column.
  • IsNotUnicode - specifies that the char property should be mapped to a non-unicode column.

The following example demonstrates how to map the char property of the Product class using the Backend Independent API.

public class FluentModelMetadataSource : FluentMetadataSource
{
   protected override IList<MappingConfiguration> PrepareMapping()
   {
       List<MappingConfiguration> configurations = new List<MappingConfiguration>();
       MappingConfiguration<Product> productConfiguration = new MappingConfiguration<Product>();
       productConfiguration.MapType().ToTable( "Products" );
       productConfiguration.HasProperty( x => x.ID ).IsIdentity( KeyGenerator.Autoinc );

       productConfiguration.HasProperty( p => p.Initials ).IsUnicode().ToColumn( "Initials" );

       configurations.Add( productConfiguration );
       return configurations;
   }
}
Public Class FluentModelMetadataSource
    Inherits FluentMetadataSource
    Protected Overrides Function PrepareMapping() As IList(Of MappingConfiguration)
        Dim configurations As New List(Of MappingConfiguration)()
        Dim productConfiguration As New MappingConfiguration(Of Product)()
        productConfiguration.MapType().ToTable("Products")
        productConfiguration.HasProperty(Function(x) x.ID).IsIdentity(KeyGenerator.Autoinc)

        productConfiguration.HasProperty(Function(p) p.Initials).IsUnicode().ToColumn("Initials")

        productConfiguration.FieldNamingRules.AddPrefix = "_"
        configurations.Add(productConfiguration)
        Return configurations
    End Function
End Class

The corresponding column will be a unicode column.

Product Class

public class Product
{
   public int ID
   {
       get;
       set;
   }

   public char Initials
   {
       get;
       set;
   }
}
Public Class Product
    Private _iD As Integer
    Public Property ID() As Integer
        Get
            Return _iD
        End Get
        Set(ByVal value As Integer)
            _iD = value
        End Set
    End Property

    Private _initials As Char
    Public Property Initials() As String
        Get
            Return _initials
        End Get
        Set(ByVal value As String)
            _initials = value
        End Set
    End Property
End Class