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

String Array Property Mapping

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.

If you have a property of type string[], this would result in a join table being created, where the values of the string array will be stored. By default, the value column in the join table will be of type varchar(255). When you configure a string property through the .HasProperty method, you are getting back a StringPropertyConfiguration object that exposes few methods for additional configuration: WithFixedLength, WithVariableLength, WithInfiniteLength, IsUnicode. These methods are also available for (normal CLR and artificial) properties of type string[]. Using that new array configuration object, you will be able to control what gets generated for the value column in the join table representing the string array.

WithFixedLength

The WithFixedLength method specifies that a string property will be mapped to a sql type requiring a fixed amount of characters. If you use this method, you will get nchar(x) or char(x) (depending on the IsUnicode setting) in the database instead of varchar(255).

productConfiguration.HasProperty( x => x.StringArray )
   .WithFixedLength(50)
   .WithArrayValue( "ArrayValue" )
   .WithTable( "Product_StringArray_JoinTable" );
productConfiguration.HasProperty(Function(x) x.StringArray).
    WithFixedLength(50).
    WithArrayValue("ArrayValue").
    WithTable("Product_StringArray_JoinTable")

WithVariableLength

The WithVariableLength method specifies that a string property will be mapped to a backend type having a maximum allowed character length (but no minimum). If you use this method, you will get either varchar or nvarchar (depending on the IsUnicode setting) instead of varchar(255).

productConfiguration.HasProperty( x => x.StringArray )
   .WithVariableLength(50)
   .WithArrayValue( "ArrayValue" )
   .WithTable( "Product_StringArray_JoinTable" );
productConfiguration.HasProperty(Function(x) x.StringArray).
    WithVariableLength(50).
    WithArrayValue("ArrayValue").
    WithTable("Product_StringArray_JoinTable")

WithInfiniteLength

The WithInfiniteLength method specifies that the property will be mapped to a backend type allowing the maximum character length possible. If you use this method, you will get either varchar(max) or nvarchar(max) (depending on the IsUnicode setting) instead of varchar(255).

productConfiguration.HasProperty( x => x.StringArray )
   .WithInfiniteLength()
   .WithSequenceColumn( "SequenceId" )
   .WithArrayValue( "ArrayValue" )
   .WithForeignKey( "ProductId" )
   .WithTable( "Product_StringArray_JoinTable" );
productConfiguration.HasProperty(Function(x) x.StringArray).
    WithInfiniteLength().
    WithSequenceColumn("SequenceId").
    WithArrayValue("ArrayValue").
    WithForeignKey("ProductId").
    WithTable("Product_StringArray_JoinTable")

IsUnicode

The IsUnicode method specifies if the backend type will be unicode or not. By using this method, you can specify if the used type will be char/varchar or nchar/nvarchar.

productConfiguration.HasProperty( x => x.StringArray )
   .IsUnicode()
   .WithSequenceColumn( "SequenceId" )
   .WithArrayValue( "ArrayValue" )
   .WithForeignKey( "ProductId" )
   .WithTable( "Product_StringArray_JoinTable" );
productConfiguration.HasProperty(Function(x) x.StringArray).
    IsUnicode().
    WithSequenceColumn("SequenceId").
    WithArrayValue("ArrayValue").
    WithForeignKey("ProductId").
    WithTable("Product_StringArray_JoinTable")