In the part 1 and the part 2 of this tutorial, I explained how create a LINQ to SharePoint Data model files and how manage your entities with the LINQ to SharePoint DSL Extension for Visual Studio 2010.

In this new post, you can found more information about the relations work in this tool, and how to manage it with this tool.

 The LINQ to SharePoint relational model

LINQ to SharePoint provide the way to manage all relations 1-1, 1-N and N-N. . The relations are defined thanks to Lookup fields in the model.

LINQ to SharePoint provides the support of the following multiplicity choices on the entities lookup fields:

Relations supported Description
SharePoint field configuration
0…1
Zero or one AllowMultipleValues=false  - Required=false
1 One
AllowMultipleValues=false  - Required=true
*
Any
AllowMultipleValues=true  - Required=false
None
None
Required=false

 In the LINQ to SharePoint conception model, you can create four kinds of relations between entities:

  • List to list:  In SharePoint, this relation is a lookup field in a list on another list
  • List to content type: In SharePoint, this relation is a lookup field in a list on another list, but the list is not represent by an entity. In the schema, the relation is symbolized by list to content type association, and you must specify the host list name on the association properties.  
  • Content type to list: In SharePoint, this relation is a lookup field in a content type on a list (for web scope content types)
  • Content type to content type: In SharePoint, this relation is a lookup on the same entities, based on a content list.

 List to list association

You can add an association between a list and another list thanks to the toolbox item. An association is symbolized in the LINQ to SharePoint DSL Extension by a line with diamond and multiplicity indicators on extremities, as in this screenshot:

If you click on the relation line, you can edit the following properties:

  • End 1 Property Name: Defines the name of the source property in the source role (type)
  • End 1 Role Name: Defines the source property type name
  • End 1 Multiplicity: Defines the multiplicity of the source property in the source role (type)
  • End 1 On Delete: Defines the comportment on the delete action on this field for this relation (Cascade, Restrict, None)
  • End 1 Property Name: Defines the name of the destination property in the source role (type)
  • End 1 Role Name: Defines the destination property type name
  • End 1 Multiplicity: Defines the multiplicity of the destination property in the source role (type)
  • End 1 On Delete: Defines the comportment on the delete action on this field for this relation (Cascade, Restrict, None)

List to content type association

If you click on the relation shape, you can edit the following properties:

  • End 1 Property Name: Defines the name of the source property in the source role (type)
  • End 1 Role Name: Defines the source property type name
  • End 1 Multiplicity: Defines the multiplicity of the source property in the source role (type)
  • End 1 On Delete: Defines the comportment on the delete action on this field for this relation (Cascade, Restrict, None)
  • End 1 Property Name: Defines the name of the destination property in the source role (type)
  • End 1 Role Name: Defines the destination property type name
  • End 1 Multiplicity: Defines the multiplicity of the destination property in the source role (type)
  • End 1 On Delete: Defines the comportment on the delete action on this field for this relation (Cascade, Restrict, None)
  • List Name: The SharePoint list name. This list contains all the lookup item values. This list name is mandatory.

The relation edition looks like it:

 

Content type to list association

If you click on the relation line, you can edit the following properties:

  • End 1 Property Name: Defines the name of the source property in the source role (type)
  • End 1 Role Name: Defines the source property type name
  • End 1 Multiplicity: Defines the multiplicity of the source property in the source role (type)
  • End 1 On Delete: Defines the comportment on the delete action on this field for this relation (Cascade, Restrict, None)
  • End 1 Property Name: Defines the name of the destination property in the source role (type)
  • End 1 Role Name: Defines the destination property type name
  • End 1 Multiplicity: Defines the multiplicity of the destination property in the source role (type)
  • End 1 On Delete:  Defines the comportment on the delete action on this field for this relation (Cascade, Restrict, None) 

The relation edition looks like it:

 

Content type to content type association

If you click on the relation shape, you can edit the following properties:

  • End 1 Property Name: Defines the name of the source property in the source role (type)
  • End 1 Role Name: Defines the source property type name
  • End 1 Multiplicity: Defines the multiplicity of the source property in the source role (type)
  • End 1 On Delete: Defines the comportment on the delete action on this field for this relation (Cascade, Restrict, None)
  • End 1 Property Name: Defines the name of the destination property in the source role (type)
  • End 1 Role Name: Defines the destination property type name
  • End 1 Multiplicity: Defines the multiplicity of the destination property in the source role (type)
  • End 1 On Delete: Defines the comportment on the delete action on this field for this relation (Cascade, Restrict, None)
  • List Name: The SharePoint list name. This list contains all the lookup item values. This list name is mandatory.

The relation edition looks like it: