Data Access has been discontinued. Please refer to this page for more information.

Overview

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.

Once you have your business object mapped to a table, you can specify additional property configuration. The Fluent Mapping API allows you to do that by using the BasicPropertyConfiguration class and its derivations. The following example shows you how to get the property configuration object of the Birthday property of the Person business object. Note that you need to use the HasProperty method, which returns you specific derive type of the BasicPropertyConfiguration class, depending on the CLR type of the target property. For example, the Birthday property of the Person object is of type DateTime. That's why the HasProperty method will return you DateTimePropertyConfiguration object.

public class MyFluentMetadataSource : FluentMetadataSource
{
   protected override IList<MappingConfiguration> PrepareMapping()
   {
       IList<MappingConfiguration> preparedConfigurations = new List<MappingConfiguration>();

       MappingConfiguration<Person> personConfiguration = new MappingConfiguration<Person>();
       personConfiguration.MapType(p => new
       {
           Id = p.Id,
           FirstName = p.FirstName,
           LastName = p.LastName,
           Birhtday = p.Birthday
       }).ToTable("People");

       DateTimePropertyConfiguration propertyConfiguration = personConfiguration.
            HasProperty(p => p.Birthday);

       preparedConfigurations.Add(personConfiguration);
       return preparedConfigurations;
   }
}
Public Class MyFluentMetadataSource
 Inherits FluentMetadataSource
 Protected Overrides Function PrepareMapping() As IList(Of MappingConfiguration)
  Dim preparedConfigurations As IList(Of MappingConfiguration) = _
        New List(Of MappingConfiguration)()

  Dim personConfiguration As New MappingConfiguration(Of Person)()
  personConfiguration.MapType(Function(p) New With {
        Key .Id = p.Id, 
        Key .FirstName = p.FirstName, 
        Key .LastName = p.LastName, 
        Key .Birhtday = p.Birthday}).ToTable("People")
  personConfiguration.FieldNamingRules.AddPrefix = "_"

  Dim propertyConfiguration As DateTimePropertyConfiguration = personConfiguration. _
        HasProperty(Function(p) p.Birthday)

  preparedConfigurations.Add(personConfiguration)
  Return preparedConfigurations
 End Function
End Class

This section provides examples of how to specify additional property configuration: