One day, a reader emailed me and asked me if I was interested in doing a translation application, according to the "Food Translation Court-English translation of Chinese menu" to the Chinese name into English dishes, because he often eat with foreigners, so I hope that his WP mobile phone can have one such application, and we just take this opportunity to explore LINQ to SQL queries and related optimization techniques.
Use the existing database
Windows Phone 7.5 Adds support for the SQL Server CE database, but Visual Studio 2010 does not provide database tool support for Windows Phone's projects, such as table design and entity class generation, and The database must also be accessed through LINQ to SQL.
In general, the application creates the database in isolated storage at the first run, and then saves the user-created data while it is running, but instead of creating a new database, it uses an existing database, which is deployed with the application to the user's mobile phone. First, add the database to the project through the Project menu in Solution Explorer, as shown in Figure 1.
Then, in properties, set the value of the database build action to content, as shown in Figure 2, so that the database will be packaged into the XAP file as a stand-alone file. In contrast, if we set the value of the build action to resource, then the database will embed the DLL file as a resource, which will cause the application to load longer and should be avoided as much as possible.