Search code examples
c#win-universal-appsqlite-net

Which SQLite.Net.Attributes to ignore object field as Column?


I am using Sqlite in Universal Windows with SQLite.Net-PCL and I wrote a class for later table creation:

[Table("my_tab")]
    public class MyObj
    {
        [PrimaryKey, Column("column1")]
        public string myObjField1 { get; set; }

        [Column("column2")]
        public string myObjField2 { get; set; }

        //???
        public string myObjField3 { get; set; }
    }

My question is how to ignore myObjField3 to be as a table column?


Solution

  • you can just use [Ignore]atribute, so it should look like:

     [Table("my_tab")]
        public class MyObj
        {
            [PrimaryKey, Column("column1")]
            public string myObjField1 { get; set; }
    
            [Column("column2")]
            public string myObjField2 { get; set; }
    
            [Ignore]
            public string myObjField3 { get; set; }
        }
    

    Simple enough, right? :)