6

如果我为 windows phone 使用 SQL Server CE,我可以选择类的哪些属性映射到数据库表。这允许我在一个类上拥有抽象属性。

例如

[Table]
public class MyClass
{
    // this property is written to the database
    private int _ItemId;

    [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
    public int ItemId
    {
        get
        {
            return _ItemId;
        }
        set
        {
            _ItemId = value;
        }
    }

    // abstract class. obviously this just an example. the real code checks for 11. =)
    // under SQLite, it looks like this will get stored in the db?
    public bool IsItemIdSeven
    {
        get{ return _ItemId == 7; }
    }
}

是否可以从 SQLite-net 中的类定义中排除属性?我不能使用扩展,因为其中一些属性被 UI 绑定使用。

4

1 回答 1

13

如果您使用的是SQLite-net,则可以使用[Ignore]属性

于 2013-08-02T15:41:55.960 回答