Databases Reference
In-Depth Information
Property Definition
A .NET property is defined by its name, type, and accessibility of its getter and setter.
public string Name { get; }
The
Name
property of the
MetaColumn
class returns the name of the entity property. It is a
raw, internal string that can be used to identify the column but might not be appropriate
for display to end users.
public Type ColumnType { get; }
public TypeCode TypeCode { get; }
The
ColumnType
property returns a
Type
object that represents the .NET type of the
entity property. For the
ProductName
property of the Product entity, this would be a
typeof(string)
. The
TypeCode
property, on the other hand, returns one of the
members of the
TypeCode
enumeration, and for the ProductName column, this would
be
TypeCode.String
.
public bool IsBinaryData { get; }
public bool IsFloatingPoint { get; }
public bool IsInteger { get; }
public bool IsLongString { get; }
public bool IsString { get; }
A set of convenience properties is also available to determine a higher-level group of the
property's data types. For example, the
IsFloatingPoint
property returns
true
for
Float
,
Double,
and
Decimal
columns; the
IsInteger
property works similarly for
Byte
,
Int16
,
Int32
, and
Int64
columns. The
IsLongString
property returns
true
if the
MaxLength
of
the string exceeds one billion characters (
1,073,741,819
to be exact). In practical terms,
this means memo columns,
TEXT
and
NTEXT
in Microsoft SQL Server, and determines
whether a
MultilineText
field template will be used for this column by default.
public int MaxLength { get; }
For binary and string columns, the
MaxLength
property returns the maximum length
allowed for the column values in the data model. For example, the ProductName column
of the Products table is limited to 40 characters, and the
MaxLength
property would return
40 by default.
using System.ComponentModel.DataAnnotations;
[MetadataType(typeof(Product.Metadata))]
partial class Product
{
public class Metadata
{