IT tutorials
 
Technology
 

LINQ to SharePoint and SPMetal : Demonstration Scenario (part 5) - Creating Entities Using SPMetal - Create a Windows Forms Sample Application

11/24/2013 6:15:35 PM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

3. Creating Entities Using SPMetal

Now that we’ve created a basic data structure, let’s make use of SPMetal to generate some entity classes. At the time of writing, SPMetal is implemented as a command line only tool. It’s installed by default at %SPROOT%\Bin\SPMetal.exe and can be called using the command line arguments in Table 1.

Table 1. SPMetal Command Line Arguments
OptionValue DefinitionExample
webThe complete, absolute URL of the web site whose data is modeled by the entity classes/web:http://localhost/Chapter14
codeThe relative or absolute path and filename of the output file/code:Chapter14.cs
languageThe programming language of the generated code/language:csharp
namespaceThe namespace that contains the entity class declarations/namespace:Chapter14.HireSample
useremoteapiNo value/useremoteapi
userThe user in whose context SPMetal executes/user:mydomain\bob
passwordThe password for the user specified in the user option/password:Pa$$w0rd
serializationSpecifies whether objects that instantiate the generated classes are serializable; if this option is not used, “none” is assumed/serialization:unidirectional
parametersIdentifies the path and name of an XML file that contains overrides of SPMetal default settings/parameters:ParameterFile.xml

The tool will produce a .cs or .vb file containing class definitions for each entity available within the site referenced by the /web: argument. Additionally, it will also create a strongly typed DataContext object with properties for each list and document library within the data structure.

3.1 Create a Windows Forms Sample Application

First things first: if we’re going to make use of LINQ, we’ll need a Visual Studio 2010 project. Create a new Windows Forms Application project. It’s important to make sure that the project is set to use .NET Framework 3.5 and not version 4.0. For ease of narrative, save the project in C:\Code\Chapter14 and call it LinqSampleApplication.

Once the project has been created, we need to take a few steps to make it compatible with SharePoint 2010. First, we need to set the build type to be 64-bit. SharePoint 2010 is 64-bit only, and by default Windows Forms Application projects are configured for 32-bit builds.

  1. From the Build menu, select Configuration Manager.

  2. Under Platform, select <New...>.

  3. In the New Project Platform dialog, select x64 from the New Platform drop-down list. Click OK to save the changes.

Next, we need to add references to the SharePoint object model:

  1. In the Solution Explorer pane, right-click References and then select Add Reference.

  2. In the dialog that appears, select Microsoft.SharePoint and Microsoft.SharePoint.Linq.

  3. Click OK to add the references.

 
Others
 
- LINQ to SharePoint and SPMetal : Demonstration Scenario (part 4) - Create a Data Structure Using SharePoint 2010 - Associate Content Types , Defining Relationships
- LINQ to SharePoint and SPMetal : Demonstration Scenario (part 3) - Create a Data Structure Using SharePoint 2010 - Create Content Types, Create Customer Template Site
- LINQ to SharePoint and SPMetal : Demonstration Scenario (part 2) - Create a Data Structure Using SharePoint 2010 - Create Site Columns
- LINQ to SharePoint and SPMetal : Demonstration Scenario (part 1)
- LINQ to SharePoint and SPMetal : LINQ to SharePoint
- LINQ to SharePoint and SPMetal : Overview of LINQ
- Microsoft Lync Server 2010 : Virtualization Overview (part 3) - Lync Support Guidelines
- Microsoft Lync Server 2010 : Virtualization Overview (part 2) - Benefits of Virtualization, Virtualization Vendors
- Microsoft Lync Server 2010 : Virtualization Overview (part 1) - Hypervisor Types
- Microsoft Lync Server 2010 : UC Endpoints (part 2) - USB Headsets, Speakerphones, and Handsets
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us