Using. Net assembly as a data connectivity data source (4)

Source: Internet
Author: User
Tags dot net visual studio 2010
ArticleDirectory
    • Procedure

In our previous blog post, we learned how to create a BCS model and define the BCS method (finder, specific finder, Id enumerator, creator and Updater ).

This article describes how to configure associations between two BCS external content types in Visual Studio 2010. In the previous article, we have used the Department table, so the employee table is the best choice for the second external content type. We will create associations between departments and employees. First, we need to establish the external content type of the employee BCS. Therefore, please open your previously used department external content type project and use the same steps to create the external content type of the employee. You don't need to define all the methods, as long as there are finder and specific finder.

Procedure

1) Make sure that you have defined the finder and specificfinder methods for the external content type of the employee. You can use the BCS business data list web parts and BCS business data list items Web parts to check whether the employee data can be correctly retrieved. Shows the BCS model diagram in Visual Studio 2010 in the current state:

The employee table contains many columns. In this example, we only use employeeid, firstname, lastname, title, and inclumentid. 2) view the toolbox in Visual Studio 2010 and click "association ".

 

3) to establish the association between Department and employee, click the association icon of the Toolkit and then click the Department entity on the interface and then the employee entity. 4) A new dialog box is displayed, where you can configure the association method. 5) in Part 1-identifier mapping, You can map Identifier from the source object to the target object. In Part 2-association methods, you can add/Delete the associationnavigator method. In our example, we will delete the employeetodepartment method, leaving only the departmenttoemployee method. 6) Click "OK" to associate the external content type of the Department (source) with the employee (target. 7) Next, we need to write C # Of the association method # Code . Open the departmentservice. CS file and you will see the automatically generated departmenttoemployee method. Use the following C # code method to replace the content. Public   Static   Ienumerable < Employee > Departmenttoemployee ( Short Departmentid)
{
Employeedatacontext DB =   New   Employeedatacontext ( " Server = localhost; database = adventureworks2000; uid = ***; Pwd = *** " );
Ienumerable < Employee > Records =   From Record In DB. Employees
Where Record. Specify mentid = Departmentid
Select New   Employee
{
Employeeid = Record. employeeid,
Firstname = Record. firstname,
Lastname = Record. lastname,
Title = Record. title,
Departmentid = ( Int16 ) Record. Specify mentid
};
Return Records;
}

 

8) press Ctrl + F5 to recompile and deploy the solution. Open the SharePoint site and enter the editing mode of the page. Drag and Drop a "business data list" Web component and a "list related to business data" Web component on the page.

 

9) Select the Department entity from the business data list webpart and select the employee entity from the relevant webpart.

 

10) We need to connect the two webparts. When the Department webpart is in editing mode, add a connection from the webpart menu.

 

11) after the connection is completed, you can click the icon in the header of each line in the department list to call the association method to display the employee records of the corresponding department.

 

 

References

Create Association Method for BCS dot net assembly

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.