【发布时间】:2013-08-02 14:50:44
【问题描述】:
如果我在 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 绑定使用。
【问题讨论】:
-
SQLite 本身不包含 ORM。你用什么做ORM?
-
如果你使用SQLite-net,你可以使用
[Ignore]属性。 -
就像@AlaaMasoud 在sqlite-net 库中所说的那样,在这种情况下,您需要使用
SQLite.IgnoreAttribute[SQLite.Ignore] public bool IsItemIdSeven { get; set; } -
谢谢大家。我使用 SQLite-net 作为 ORM。在 SQLite 本身和 SQLite-net 之间有点困惑。如果你们中的一个人将此作为答案提交,我会接受。我也在更新问题以消除混淆
标签: sqlite windows-phone-8 sql-server-ce sqlite-net