Tuesday, March 1, 2011

SPMetal in SharePoint 2010

In this article we will discuss about the SPMetal and also how to use SPMetal in SharePoint 2010. Also you can visit article on LINQ to SharePoint 2010.
SPMetal is a command-line tool that generates entity classes. These classes are primarily used in LINQ to SharePoint queries. The classes it generates are partial, so you can add members to them in separate, manually created, code files.

SPMetal comes in SharePoint 2010 and it founds in %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\BIN.

By using this you can generate a code file that contains classes for your objects in a specific site.
This will include a data context object, along with objects for all of your list level content types.
All the objects are strongly typed objects.
SpMetal.exe -url: -list: [-out:] [-language:]
[-user: -password: [-domain:]]

-url: URL to the root of the SharePoint site
-list: Name of the list
-out: Output file
-language: Code language used for output (VB or CS)
(Default: CS)
-user: User name for connection to SharePoint site
-password: Password for connection to SharePoint site
-domain: Domain for connection to SharePoint site

Ex. SPMetal /web:http://SiteName/SubSiteName /code:FileName.cs
Also you check some good SharePoint Tools.

No comments:

Post a Comment