4-16: Creating a New Item Using SPLINQ in .NET

Encoding QR Code in .NET 4-16: Creating a New Item Using SPLINQ
Listing 4-16: Creating a New Item Using SPLINQ
Printing QR Code JIS X 0510 In Visual Studio .NET
Using Barcode maker for VS .NET Control to generate, create Quick Response Code image in .NET framework applications.
          
QR Decoder In Visual Studio .NET
Using Barcode scanner for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications.
 
Drawing Bar Code In .NET
Using Barcode generation for .NET framework Control to generate, create bar code image in VS .NET applications.
   
Reading Barcode In .NET
Using Barcode scanner for VS .NET Control to read, scan read, scan image in .NET framework applications.
  
Denso QR Bar Code Generation In C#.NET
Using Barcode printer for Visual Studio .NET Control to generate, create QR-Code image in .NET framework applications.
Creating Lists
QR Maker In .NET Framework
Using Barcode printer for ASP.NET Control to generate, create Denso QR Bar Code image in ASP.NET applications.
If you don t have items in the list already run the code a couple of times and update the budget properties for each run Now that you have a couple of budget items in the list, you can replace the code in your console app that creates a new item with the code shown in Listing 4-17 The first two lines of code are identical to the ones we implemented for creating a new item The first line of the code gets the data context object Then we need to use the default credentials from the credential cache again in order to be able to access the data In the next line the local variable budgetListItems is initialized with a LINQ query expression returning an IEnumerable of BudgetListItem The query expression operates on the BudgetList source by applying the select operator This expression also uses the orderby operator to order the result by Budget Lastly we iterate through the collection and print out the values for the Budget, Usage, and Title properties of that item
QR Code Generation In VB.NET
Using Barcode printer for VS .NET Control to generate, create QR Code ISO/IEC18004 image in Visual Studio .NET applications.
Listing 4-17: Retrieving All Items in a List Using SPLINQ
Code 128B Encoder In .NET Framework
Using Barcode encoder for .NET framework Control to generate, create Code 128B image in VS .NET applications.
           
Draw UPC - 13 In .NET Framework
Using Barcode printer for Visual Studio .NET Control to generate, create EAN-13 Supplement 5 image in .NET framework applications.
  
Drawing Barcode In .NET
Using Barcode creation for .NET Control to generate, create bar code image in .NET applications.
  
Code 3 Of 9 Creation In VS .NET
Using Barcode generation for .NET framework Control to generate, create Code-39 image in .NET framework applications.
This small sample should give you an idea about how great and easy it is to work with list data using SPLINQ You want to retrieve items meeting a certain criteria, for example items with a budget greater than $200 You just add a where clause with that condition to the LINQ query The query will return only the items meeting that criteria Listing 4-18 shows code that only returns the budget items whose Budget value is $20, updates the value of the
Making Planet In VS .NET
Using Barcode encoder for Visual Studio .NET Control to generate, create USPS PLANET Barcode image in VS .NET applications.
4: SharePoint Lists
Barcode Drawer In VB.NET
Using Barcode generator for .NET Control to generate, create barcode image in .NET applications.
first found item to 21, and writes it back to the server Because we only care that one item meets the criteria we can use the Single() operator to only return one element Before we can write it back to the store we need to call the UpdateObject method so the data context knows that the object has been modified This step is needed, otherwise no change would occur on the server
Bar Code Encoder In C#
Using Barcode encoder for .NET Control to generate, create barcode image in .NET framework applications.
Listing 4-18: Updating an Item in a List Using SPLINQ
Decoding Code 128B In .NET Framework
Using Barcode recognizer for .NET Control to read, scan read, scan image in .NET applications.
            
Make UPC-A In Java
Using Barcode encoder for Java Control to generate, create Universal Product Code version A image in Java applications.
To delete the same item we only need to replace the UpdateObject method with the DeleteObject method as shown in Listing 4-19
Printing Code39 In Java
Using Barcode drawer for Java Control to generate, create Code 39 Extended image in Java applications.
Listing 4-19: Deleting an Item in a List Using SPLINQ
Generating DataMatrix In C#
Using Barcode encoder for .NET framework Control to generate, create DataMatrix image in .NET framework applications.
           
Painting Bar Code In Java
Using Barcode creator for Java Control to generate, create barcode image in Java applications.
In the last four examples we learned how to use SPLINQ to implement basic Create/Read/Update/Delete (CRUD) operations Of course SPLINQ
Encode Barcode In VB.NET
Using Barcode encoder for Visual Studio .NET Control to generate, create bar code image in .NET applications.
Conclusion
is much more powerful You can implement queries across multiple lists with relationships and more You can find further information on SPLINQ in the SharePoint Software Development Kit (SDK)
List Relationships What Are Those
OK, we can t cover everything about SharePoint, the book would be 1500 pages long But here s a quick idea about list relationships Think about a list with customers that is the parent list and a list with orders that is the child list SharePoint allows you to set referential integrity constraints on the child items by specifying a delete behavior For example, we could enforce that customers who have an order cannot be deleted List relationships can be defined through the user interface or through the object model using the SPRelatedField class
Conclusion
In this chapter we looked at creating lists and list templates in SharePoint Designer and creating list instances and list definitions in Visual Studio Further we discussed how to programmatically create lists using the server object model and the client object model We also looked into which scenarios should use which object model We spent the end of the chapter looking into various ways to work with list data itself We created CRUD samples for list items using the server-side object model, the client-side object model, and LINQ to SharePoint