In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to implement the ADO.NET entity data model". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to realize the ADO.NET entity data model.
ADO.NET is the core of the interoperation between .NET and database, while ADO.NET entity database enhances the interconnection ability between .NET application and database. Through the ADO.NET entity data model, we can easily interoperate with the underlying database. It greatly facilitates the designers, and thus improves the security of database operation. Recently, we encountered a very special problem when using Silverlight's domain data service [the results in the application are different from those in the database]. After repeated experiments, we finally found the root of the problem, that is, the ADO.NET entity data model relies on entity keys, and its queries generate a unique result set of entity keys.
Now let's take a look at the specific operation process and handling methods:
In order to operate on the tables of the database, a view of vw_DesksAndUsers that connects two atomic tables is established in the view of the database, which is designed to join the existing User table and the data of Desk, so I made the following view of T-SQL, as shown below:
The query result in SQL Server 2008 is as follows:
In other words, the expected results were achieved, [this step was very successful]. Let's move on to step two.
Step 2: create a new Silverlight business application SilverlightDomainDb that will support WCF RIA services in the generated project. This is required for support of Silverlight domain services.
Step 3: add a new item of ADO.NET entity data model to the Web project, select the corresponding database connection and data table, view and stored procedure in the wizard, and generate the corresponding entity data type and context after completion, and get the model diagram of .edmx. As follows:
At the prompt of Visual Studio 2010, it generated two entity keys for us: DeskId,IsPlaying (these are the two fields in the Desk table); now rebuild the project.
Step 4: add Web domain service items according to the entity model. (you need to add the appropriate table and metadata information in this step)
Step 5: in the Silverlight project, drag the Datagrid of the vw_DesksAndUsers where the data source is located to Home.xaml, complete and debug. Instead of getting the above result, the following Datagrid is generated:
After careful observation, it is found that the result set in the ADO.NET entity data model depends on the entity key, that is, the Silverlight domain service generates the result set of the query based on the unique entity key, thus generating the above data with DeskId as the unique key.
Deal with:
According to the above analysis, in order to get the expected results, we must set the appropriate entity key. In order not to affect the underlying SQL database, we only need to modify the entity key in the .edmx model diagram (right-click to select or uncheck "entity key"):
Now rebuild the project and run the program, and the program gets the expected results.
Silverlight business application, as a template designed for data display, provides a friendly interface for the presentation of the database. Because of its optimized database processing, we have to consider some nuances between them. [since I can't see the T-SQL query generated by LINQ in Visual Studio, I only provide a simple solution] I think the underlying reason is that the T-SQL statements generated in LINQ queries are different from the T-SQL statements in the database.
Thank you for your reading, the above is the content of "how to achieve the ADO.NET entity data model". After the study of this article, I believe you have a deeper understanding of how to achieve the ADO.NET entity data model, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.