Windows apps
Collapse the table of content
Expand the table of content
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: Represent Columns as Class Members (LINQ to SQL)

Use the LINQ to SQL ColumnAttribute attribute to associate a field or property with a database column.

To map a field or property to a database column

The following code maps the CustomerID field in the Customer class to the CustomerID column in the Customers database table.

<Table(Name:="Customers")> _
Public Class Customer
    <Column(Name:="CustomerID")> _
    Public CustomerID As String 
    ' ... 
End Class

You do not have to specify the Name property if the name can be inferred. If you do not specify a name, the name is presumed to be the same name as that of the property or field.

Community Additions

Show:
© 2017 Microsoft