Export (0) Print
Expand All

Type Mapping: From LINQ to SharePoint Provider to .NET

SharePoint 2010

Last modified: February 02, 2011

Applies to: SharePoint Foundation 2010

This article shows how the LINQ to SharePoint provider maps Microsoft SharePoint Foundation field (column) types onto Microsoft .NET Framework types.

Field Type

.NET Type

Comments

AllDayEvent

Boolean

Attachments

Boolean

Boolean

Boolean

Calculated

Type of the returned value

Choice

Enum or String

See Choice and MultiChoice Fields.

Computed

Object

ContentTypeId

Byte []

Counter

Int32

CrossProjectLink

Boolean

Currency

Double

DateTime

DateTime

File

String

GridChoice

Object

Guid

Guid

Integer

Int32 or Nullable<T>, where T is Int32.

Lookup

See Lookup Fields.

MaxItems

Object

ModStat

Object

MultiChoice

Flagged Enum or String

See Choice and MultiChoice Fields.

Note

String

Number

Double

PageSeparator

Object

Recurrence

Boolean

Text

String

ThreadIndex

Object

Threading

Object

URL

String

User

A User field is a lookup field to the User Information List (which is a hidden list by default). See Lookup Fields.

WorkflowEventType

Object

WorkflowStatus

Object

Choice and MultiChoice Fields

The type mapping of Choice and MultiChoice field types depends on whether "Fill-in" choices are allowed and on how many choices there are as specified in the following table.

Fill-in Choices Not Allowed and Fewer than 31 Choices Available

Fill-in Choices Not Allowed and more than 30 Choices Available

Fill-in Choices Allowed

Choice Fields

A Microsoft .NET Framework enum type with all of the available choices numbered starting with 1. The enum includes an Invalid value (-1) and a None value (0). The class is named FieldNameChoices, where FieldName is the name of the field.

<-- Same as to the left.

String . (SPMetal creates a sealed class that contains a set of String constants, one for each available choice.)

MultiChoice Fields

Same as the previous, except that the enum is flagged.

Same as to the right -->

IList <String>. (SPMetal creates a sealed class that contains a set of String constants, one for each available choice.)

Lookup Fields

The type mapping of Lookup and User fields depends on whether the field allows multiple values or not, and on whether the target list is represented in the code generated by SPMetal, which it may not be if the target list is hidden or SPMetal is configured to exclude the list. The following table shows the possibilities.

Multiple Values Not Allowed

Multiple Values Allowed

The Target List is Represented in the Generated Code

When the target list is represented in generated code, the Lookup field does not map to any .NET Framework basic type.

SPMetal generates a private field type EntityRef<TEntity> where the TEntity is the content type of the target list, not the type of the target column. This property is wrapped in a generated property of type TEntity.

The remarks to the left apply here also, except that the field is represented as both a private field and a property of type EntitySet<TEntity>, where TEntity is the content type of the target list.

The Target List is not Represented in the Generated Code

The field is represented twice in the object-relational mapping:

  • As a property of type String (regardless of what .NET Framework type is mapped to the target field of the target list).

  • The property wraps a private String field.

In addition, a second property/field pair is generated to represent the ID field of the target list. Both the field and property are type Nullable<T>, where T is Int32.

The field is represented twice in the object-relational mapping:

  • As an IList<T> property, where T is String (regardless of what .NET Framework type is mapped to the target field of the target list).

  • The property wraps a LookupList<T> field, where T is String.

In addition, a second IList<T> property and LookupList<T> field pair is generated to represent the ID field of the target list. The T for both is a Nullable<T>, where T is Int32.

Note Note

A User field is a lookup field to the User Information List. The latter is hidden, so by default, SPMetal does not generate code to represent it.

Show:
© 2014 Microsoft