Muhammad Ali Khan

MS CRM 3.0, MS CRM 4.0, Sharepoint 2007 & Sharepoint 2010

New Features of List in SharePoint 2010 (Part 1/2)

Posted by Ali Khan on December 20, 2009

In this post, I will describe some of the new things introduced with lists in SharePoint 2010.

Some of these things are

1. Referential Integrity:-

As you know, with SharePoint 2007 we can create relationship between lists using Lookup field. But now, List in SharePoint 2010 also supports Referential Integrity with another list. So if you have two lists Student and Department, you can create a referential integrity constraint (Cascade Delete or Restrict Delete) between them.

  1. Cascade Delete: Means if item in the parent list is deleted all the associated items in the child list will also be deleted (just like in SQL Server)
  2. Restrict Delete: If an item in parent list is associated to items in the child list, then this item in parent list cannot be deleted unless its association with all the items from the child list is removed.

Here in below example, I have created two List “Student” & “Department”. And now I am creating a relationship between “Student” and “Department”. For this I have to create a column in “Student” list. See the diagram below. (Also see the referential integrity constraint between the two list set to “Restrict Delete”, which means the “Department” cannot be deleted if there are one or more “Student” related to it, just like between any two SQL tables).



2. Projected Fields in Lists:-

These are fields from the parent list which will appear in the view of the child list. These are additional fields from the parent list to be shown in the child list. E.g. from the above diagram, Department Location from the department will be shown in the student list. These fields are NOT saved in the child list (Student) and will be only shown in the child list. See the diagram below. Here the “Department Location” is a “Project Field” from the “Department” list to be shown in the “Student” list, but it is not saved in the “Student” list.



3. Unique Columns:-

You can create unique column (meaning the column will hold the unique data) inside a list in SharePoint 2010. The unique column MUST be indexed. So while creating the unique column, SharePoint 2010 will ask you to index the Unique Column. E.g. Student “Registration No” can be a unique column in the “Student” list. You can also make any existing column as unique column provided it has unique data for all the list items.

4. JOIN and Querying Data from Two Lists:-

Developers can query the SharePoint 2010 List using CAML and LINQ to SharePoint and select fields from two different lists as shown in the code below. Here in the below code ( LINQ To SharePoint), I have retrieved all the “Students” for the Department “Computer Science”.

Note: – In order to use LINQ to SharePoint you have to generate the “SharePoint Context” from the SPMetal tool (now comes as a part of SharePoint 2010), which is located at the following directory. (“C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN”). Here is syntax to generate your Context.cs file.

SPMetal /web:http://mossserver:8000 /namespace:SPTeamSite /code:SPTeamSite.cs

After this create a new project in VS2010, add the reference to Microsoft.SharePoint.Linq.dll & Microsoft.SharePoint.dll located at the following directory. (“C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI”). Also add the SPTeamSite.cs file generated from the SPMetal tool. See the diagram below.


Now here is the code to retrieve all the “Students” of a particular “Department”.



Lists in SharePoint 2010 have a lot more to offer. I will do more posting on the new features of Lists in SharePoint 2010 as I learn more about it.

Cheers 🙂


2 Responses to “New Features of List in SharePoint 2010 (Part 1/2)”

  1. Jarrod Newton said

    Very nice, I sure will be coming back more often. I bookmarked your site also, thank you.

  2. Appreciate this. Very interesting writing.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: