IT tutorials
 
Technology
 

LINQ to SharePoint and SPMetal : Demonstration Scenario (part 6) - Creating Entities Using SPMetal - Generate Entity Classes

11/24/2013 6:16:41 PM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
3.2 Generate Entity Classes

We’re now ready to use SPMetal to generate entity classes for our extranet sample. Open a command prompt, change the current directory to C:\Code\Chapter14\ LinqSampleApplication, and then execute the following command (note that this command should be entered on a single line, not on two lines as shown here):

%SPROOT%\bin\SPMetal.exe /web:http://localhost/Chapter14/CustomerTemplate / →
code:HireSample.cs



Tip

Define a system variable to point to SharePoint root; it saves a whole load of time instead of typing C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\. Instead you can simply type %SPROOT% as a shortcut.


SPMetal will create a new file named HireSample.cs in the project directory for our LinqSampleApplication. To add it into the project, select Add Existing Item from the Project menu, and then select the file named HireSample.cs.

Have a look at the code in HireSample.cs. You’ll notice that each class is declared using the partial keyword. This allows you to extend the functionality of the auto-generated classes using additional files so that if the classes are automatically regenerated using SPMetal, any customizations are not lost.

Figure 3 shows the objects that are defined in HireSample.cs. You’ll notice that a HireSampleDataContext class that’s derived from DataContext has been defined and has properties corresponding to each of the three lists: AssetNotes, HireContracts, and OnHireAssets. Additionally, there are two classes derived from AssetNote and OnHireAsset, named AssetNotesAssetNote and OnHireAssetsOnHireAsset. These derived classes contain the additional lookup values that we added to define the relationships between the content types. Since the lookup values were not added to the content type for reasons mentioned earlier, a new derived class exists containing only the lookup field.

Figure 3. Generated entity class diagram

 
Others
 
- LINQ to SharePoint and SPMetal : Demonstration Scenario (part 5) - Creating Entities Using SPMetal - Create a Windows Forms Sample Application
- 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
 
 
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