Windows Phone local database (sqlce): 7. database mapping)

Source: Internet
Author: User

 A newbie recently wants to learn about the Windows Phone database and find some short tutorials. Because it is in English, it is translated by the way. The English level is not good. It is estimated that there are many mistakes in the text. If you have any children's shoes that are unfortunately read, please keep in doubt about the translation quality and give me more advice.

This is the original address: http://windowsphonegeek.com/tips/Windows-Phone-Mango-Local-Database-SQL-CE--Database-mapping

The text is as follows:

This is a short film in the "Windows Phone mango local database (sqlce)" series.Article. To get you started using databases in Windows Phone mango, this series of short clips will cover all the things you need to know. I will talk about ing classes to tables in the database, that is, ing between your object model and database mode.

 

1. What is database mapping? To create a local database, you must first define the object class. These classes define the ing between your object model and its database mode. The object-to-SQL relationship capability depends on the detailed information of the ing. In this way, a relational database is created to map to the corresponding datacontext. For each object, you can use the LINQ ing of LINQ to SQL to specify the detailed information of the ing. These features specify database features such as tables, columns, primary keys, and indexes. You can view more information at http://msdn.microsoft.com/zh-cn/library/bb386971.aspx. Reference: You can take a look at the msdn documentation: http://msdn.microsoft.com/zh-cn/library/hh202860 (V = vs.92). aspx 2. Understand database ing Use the property ing type to table and attribute to column: (1) in the database, to map object classes to tables, the object class can be considered as [Table] attribute. (2) [Index] attribute can be used (on the class) to define indexes. (3) in the database, to map object attributes to columns, the object attribute can be considered as [column] attribute. [Column (isprimarykey = true)] Specifies the primary key attribute. Use [Association] attribute to specify the Association, which allows you to configure the relationship between two tables/entities in the database ing.   Association attribute has the following important attributes:
    • Otherkey-the name of the property corresponds to the ID of the object at the other end of the Association
    • Thiskey-the attribute name corresponds to the primary key of the type
    • Storage-supported attributes
  Use Windows Phone mangoCodeIt is preferred to prioritize methods to define database patterns, that is, there is no visual designer available to help developers in ing and configuring their classes to process databases. Or at least it is not officially supported. This means that you must: 1. Configure ing attributes 2. Write all the classes by yourself 3. If the database does not exist, write code to create it. 4. If you want to upgrade the old database version to a new function, you must write the code again. In this article, I have discussed the tables mapped from the class to the database on the Windows Phone mango local database. Keep an eye on other articles.

 

Related Article

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.