SQLVariant Support
Microsoft introduced the sql_variant data type in SQL Server 2000. You can use the sql_variant to store data of an unspecified or inconsistent type. Or to store data of almost any SQL Server data type. This is very useful for an input parameter for a stored procedure that can handle many different data types, or a column in a table with heterogeneous data.
More information about the sql_variant data type could be found here.
Telerik Data Access provides support for the sql_variant data type. In order to use such a column, the column needs to be mapped to a persistent field of type object. For example:
The MyEntity Class
public partial class MyEntity
{
private int _iD;
public virtual int ID
{
get { return this._iD; }
set { this._iD = value; }
}
private string _name;
public virtual string Name
{
get { return this._name; }
set { this._name = value; }
}
private Object _sqlVariantColumn;
public virtual Object SqlVariantColumn
{
get { return this._sqlVariantColumn; }
set { this._sqlVariantColumn = value; }
}
}
Partial Public Class MyEntity
Private _iD As Integer
Public Overridable Property ID() As Integer
Get
Return Me._iD
End Get
Set(ByVal value As Integer)
Me._iD = value
End Set
End Property
Private _name As String
Public Overridable Property Name() As String
Get
Return Me._name
End Get
Set(ByVal value As String)
Me._name = value
End Set
End Property
Private _sqlVariantColumn As Object
Public Overridable Property SqlVariantColumn() As Object
Get
Return Me._sqlVariantColumn
End Get
Set(ByVal value As Object)
Me._sqlVariantColumn = value
End Set
End Property
End Class
Mapping the sql_variant Column
configuration.HasProperty(x => x.SqlVariantColumn).
HasFieldName("_sqlVariantColumn").
WithDataAccessKind(DataAccessKind.ReadWrite).
ToColumn("SqlVariantColumn").IsNotNullable().
HasColumnType("sql_variant");
configuration.HasProperty(x => x.SqlVariantColumn).
HasFieldName("_sqlVariantColumn").
WithDataAccessKind(DataAccessKind.ReadWrite).
ToColumn("SqlVariantColumn").IsNotNullable().
HasColumnType("sql_variant")