Compartilhar via


DataContext Constructor

Initializes a new instance of the DataContext class that provides access and change tracking for the specified Web site.

Namespace:  Microsoft.SharePoint.Linq
Assembly:  Microsoft.SharePoint.Linq (in Microsoft.SharePoint.Linq.dll)

Syntax

'Declaration
Public Sub New ( _
    requestUrl As String _
)
'Usage
Dim requestUrl As String

Dim instance As New DataContext(requestUrl)
public DataContext(
    string requestUrl
)

Parameters

  • requestUrl
    Type: System.String

    The URL of a Microsoft SharePoint Foundation Web site.

Remarks

An object created with this constructor is bound to the Microsoft SharePoint Foundation server object model. To bind a DataContext object to the Microsoft SharePoint Foundation client object model, use the #ctor(String, Boolean) constructor with true as the second parameter.

Examples

The following are examples of this constructor being used. For more information about creating DataContext objects, see How to: Query Using LINQ to SharePoint.

DataContext teamSite = new DataContext("http://MarketingServer/SalesTeam");

DataContext teamSite = new DataContext(SPContext.Current.Web.Url);

DataContext topLevelSite = new DataContext(“https://localhost”);
Dim teamSite As New DataContext("http://MarketingServer/SalesTeam")

Dim teamSite As New DataContext(SPContext.Current.Web.Url)

Dim topLevelSite As New DataContext("https://localhost")

See Also

Reference

DataContext Class

DataContext Members

Microsoft.SharePoint.Linq Namespace