Wp7 can use SqlCE as a local database, so how to create a database index.
When a table is created and a primary key is specified, the database is set to an index by default. How can I manually set a column as an index?
After querying MSDN, we found that adding [Index] to define a column before the table class, but you must add the following two reference statements at the top of the code file:
using Microsoft.Phone.Data.Linq;
using Microsoft.Phone.Data.Linq.Mapping;
Common attributes of LINQ ing to SQL:
Attribute |
Example |
Description |
TableAttribute |
[Table] |
Specify a class as the object class associated with the database table. |
ColumnAttribute |
[Column (IsPrimaryKey = true)] |
Associate a class with columns in a database table. IsPrimaryKey specifies the primary key. By default, an index is created for it. |
IndexAttribute |
[Index (Columns = "Column1, Column2 DESC", IsUnique = true, Name = "MultiColumnIndex")] |
Write Data at the table level, specifying other indexes on the table. Each index can cover one or more columns. |
AssociationAttribute |
[Association (Storage = "ThisEntityRefName", ThisKey = "ThisEntityID", OtherKey = "TargetEntityID")] |
Specify the associated attributes, for example, the foreign key associated with the primary key. |
Http://msdn.microsoft.com/zh-cn/library/hh202860 (v = vs.92). aspx