Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

How to: Define Data Fields

You can add fields to an entity or a table in the LightSwitch database. You can also modify the appearance and behavior of these fields.

This topic contains the following sections:

link to video For a related video demonstration, see How Do I: Format Data on a Screen in a LightSwitch Application?.

You can add fields to a table. In an entity that is generated from an external data source, you can add computed fields only.

For more information about computed fields, see How to: Add a Computed Field.

To add a data field

  1. In Solution Explorer, double-click an entity or table.

    The entity or table opens in the Data Designer.

  2. In the Name column, click <Add Property>, and then type a name for the field.

  3. In Type column, select a data type for the new field. The following table describes each type.

    Type

    Visual Basic Type

    C# Type

    Range

    Remarks

    Binary

    Byte()

    byte[]

    -128 to 127.

    An array of bytes that has a variable length.

    Boolean

    Boolean

    bool

    True or false.

    Date

    DateTime

    DateTime

    A DateTime that is treated as a date only.

    DateTime

    DateTime

    DateTime

    12:00:00 AM, Jan 1, 0001 through 11:59:59 PM, Dec 31, 9999.

    Decimal

    Decimal

    decimal

    ±1.0 × 10<sup>−28</sup> to ±7.9 × 10<sup>28</sup>.

    A fixed decimal point with 28-29 significant digits; good for accounting numbers.

    Double

    Double

    double

    ±5.0e−324 to ±1.7e308.

    A floating decimal point with 15-16 digits precision; good for scientific numbers.

    Email Address

    String

    string

    A string that is treated as an email address.

    Image

    Byte()

    Byte[]

    A binary that is treated as an image.

    Short Integer

    Short

    short

    -32,768 to 32,767.

    A signed 16-bit integer.

    Integer

    Integer

    int

    -2147483647 to 2147483647.

    A signed 32-bit integer.

    Long Integer

    Long

    long

    -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.

    A signed 64-bit integer.

    Money

    Decimal

    decimal

    A decimal that is treated as a monetary value.

    Phone Number

    String

    string

    A string that is treated as a phone number.

    String

    String

    string

    A sequence of zero or more Unicode characters that has a variable length.

  4. If you want to require users to provide a value for this field, select the Required check box.

You can modify a field by editing the properties of the field in the Properties window.

If the entity was generated from an external data source, some field properties will not be editable because they reflect configuration settings of the data source.

LightSwitch does not enable you to override those settings by changing field properties. You must make changes to these fields on the server and then import those changes into LightSwitch by refreshing the data source.

To modify a field

  1. In the Data Designer, click the field that you want to modify.

  2. On the View menu, click Properties Window.

  3. In the Properties window, set property values.

    For more information about each property, see Reference: Data Designer Properties.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft