Windows Phone: How do I exclude columns/properties in SQLite-net?
Asked Answered
Y

1

6

If I use SQL Server CE for windows phone I can select which properties of a class map to database tables. This allows me to have abstract properties on a class.

for instance

[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; }
    }
}

Is it possible to exclude properties from a class definition in SQLite-net? I can't use extensions as some of these properties are used by UI Bindings.

Younger answered 1/8, 2013 at 15:22 Comment(4)
SQLite doesn't include ORM by itself. What are you using for ORM?Heelpiece
If you are using SQLite-net you can use [Ignore] attribute.Oysterman
Like @AlaaMasoud say in sqlite-net library in this case you need to use the SQLite.IgnoreAttribute [SQLite.Ignore] public bool IsItemIdSeven { get; set; }Varro
thanks guys. I am using SQLite-net as an ORM. got a bit confused between SQLite itself and SQLite-net. If one of you submits this as an answer I'll accept it. I'm also updating the question to eliminate confusionYounger
O
13

If you are using SQLite-net you can use [Ignore] attribute

Oysterman answered 2/8, 2013 at 15:41 Comment(1)
Alaa Im having problems with Ignore in Windows Phone, do you know of any work around?Brae

© 2022 - 2024 — McMap. All rights reserved.