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.

4
  • SQLite doesn't include ORM by itself. What are you using for ORM? Aug 1, 2013 at 18:19
  • If you are using SQLite-net you can use [Ignore] attribute. Aug 1, 2013 at 20:04
  • Like @AlaaMasoud say in sqlite-net library in this case you need to use the SQLite.IgnoreAttribute [SQLite.Ignore] public bool IsItemIdSeven { get; set; } Aug 2, 2013 at 6:30
  • 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 confusion
    – roryok
    Aug 2, 2013 at 9:02

1 Answer 1

13

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

1
  • Alaa Im having problems with Ignore in Windows Phone, do you know of any work around?
    – Juan
    Jul 2, 2015 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.