ESqlBlast is currently a good query tool for EF, similar to the query Analyzer of MS-SQL SERVER, provides a simple intelliisense function, you can query EDM through eSQL (Entity SQL, output query results. In addition, it can directly view the current entity set and SQL statements generated through eSQL. ESqlBlast is very convenient to use. This article uses eSqlBlast to implement some query instances to familiarize themselves with how to use eSqlBlast.
1. To complete the instances in this article, you need to make the following preparations:
- Upgrade Visual Studio 2008 and. NET Framework 3.5 to SP1. Click to go to the upgrade address.
- Install SQL server 2005, and use the EXPRESS version of SQL SERVER in VS 2008.
- Download and append the database: Click to download DemoDbV2.
- Maps the database to the object. For more information, see the article "ADO. NET Entity Framework test-Shadow.
- Download eSqlBlast: Click to switch to CodePlex.
Ii. Compile the eSqlBlast Project
. No more nonsense.
3. Set the EDM output format
When configuring eSqlBlast connections, you need to use the csdl, ssdl, and msl files. These three files are generated by the. EDM file, but in VS2008SP1, these three files are not output by default. Therefore, we need to set the "Metadata Artifact Processing" attribute of the EDM file to "Copy to Output Directory ". See.
Figure 1
In this way, after re-compilation, three files corresponding to the conceptual model will appear in the project Output Folder. For future use.
4. Query
1. Configure the connection
Run microsoft.samples.data.esqlblast.winshell.exe. The following interface is displayed:
Figure 2
Here, we need to configure two parts. The first part is the connection string, which can be copied from the app. configConnectionString element. Note that you only need to copy the part after "provider connection string =. Remove the two "& quot ;". In the Metadata section, you can click Add Files and Add the three Files that have just been generated at one time. Of course, if you are lazy, you can also directly point to the Folder with the three files through Add Folder. The effect is basically the same.
After the configuration is complete, you can click "Connect" to complete the connection. After correct connection, the status bar at the bottom shows the green "Connected.
Figure 3
2. view the conceptual model Overview (this step can be omitted without affecting the query)
To view the Overview of the current conceptual model, go to the second page and select. click "Render" after the csdl file to view the parsed file. the "entity set", "entity class", "complex type", and all "Connections" of the conceptual model described by csdl ". See.
Figure 4
3. Enter an eSQL statement.
Let's go to the most interesting part. Click the "Query" tab and use eSQL for some queries. We recommend that you do not use the "copy and paste algorithm". Enter eSQL to try eSqlBlast to write eSQL. ^_^
We have two instances:
1. Check all the laptops.
Select ValuePFromNbWhEntities. NotebookAsP;
2. query the status of two laptops from the third record (sort brand names)
Select ValuePFromNbWhEntities. NotebookAsPOrder ByP. BrandSkip2Limit2;
When the input is from, intelligent sensing will appear, such:
Figure 5
4. View output results
The results are also clear:
Figure 6
The first part is the eSQL statement we output;
The second part is the generated SQL statement;
The third part is the number of Result Records;
Finally, the record details are listed.
The result of the second example is as follows:
Figure 7
V. Summary
Although eSqlBlast is not perfect, it is a little complicated to write a connection string and select three files at the beginning (Unlike SQL SERVER, you can choose a SERVER or enter a user name or password to connect to it) smart sensing is not perfect, and does not support parameter-based queries at the moment. However, its query function and the function of viewing generated SQL statements are quite practical. In addition, eSqlBlast is a good tool for learning and debugging eSQL.