LINQ to SharePoint does bring us a lot of convenience, saving us from the hassle of using calm, but when we use the spmetal tool (spmetal details) this tool does not work on the external list. For other restrictions on the external list, see (restrictions on SharePoint Study Notes --- splist -- external list ),
In some special cases, we need to use LINQ to Sharepoint to query the data in the external list. To solve this problem, we only need to use an alternative method, the method here is limited to the query function. The idea is to create a customer list and create a lookup field on this list to quickly reference the field on the external list (avoiding manual orCodeThe trouble of creating the required fields), and then use LINQ to SharePoint on this customer list. Therefore, the implementation is roughly divided into three parts (each part can also be used separately ).
1. Create an external list through BCS.
2. Create a customer list and quickly copy the items of the external list to the lookup field group of the customer list through code.
{SharePoint Study Notes --- splist -- indirect query of external list using LINQ to SharePoint (2. Copy external list content)
}
3. Use LINQ to SharePoint on the customer list to indirectly query the external list data through such a replacement.
{SharePoint Study Notes --- splist -- indirect query of external list by using LINQ to SharePoint (3. query list content by using LINQ to SharePoint )}
This article describes the first step: Create an external list by using BCS. The data source we use is the SQL Server database northwind.
We will create an external list (named nwcustomer) on our test website ). The procedure is as follows.
1. Open our website in SharePoint designer and go to the external content type Creation Interface
2. on the external content type creation page, click external content type (new) to create a new external content type.
3. Search for external data sources and define related operations
Add new external data source connection
Define external data source types
Define External SQL server data source connection Parameters
Define operations for external data sources
All the way to next
4. Use the BCS connection just created on the test website
On the more options page, select the create external list option.
Set related parameters (LIST Parameters and BCS connection parameters)
The following are the nwcustomer display results after creation:
Next article:SharePoint Study Notes --- splist -- indirect query of the external list using LINQ to SharePoint (2. Copy the external list content)