Defining a Discoverable Entity

The key to the OpenNETCF.ORM framework is that you must provide attributes on your Entity classes that provides a definition of your entity.

Example
    public enum BookType
    {
        Fiction,
        NonFiction
    }

    [Entity(OpenNETCF.ORM.KeyScheme.Identity)]
    public class Book
    {
        [Field(IsPrimaryKey=true)]
        public int BookID { get; set; }

        [Field]
        public int AuthorID { get; set; }

        [Field]
        public string Title { get; set; }

        [Field(SearchOrder=FieldSearchOrder.Ascending)]
        public BookType BookType { get; set; }
    }

    [Entity(OpenNETCF.ORM.KeyScheme.Identity)]
    public class Author
    {
        [Field(IsPrimaryKey = true)]
        public int AuthorID { get; set; }

        [Reference(typeof(Book), "AuthorID", Autofill=false)]
        public Book[] Books { get; set; }

        [Field(SearchOrder = FieldSearchOrder.Ascending)]
        public string Name { get; set; }
    }

Last edited Feb 25, 2016 at 2:52 AM by ctacke, version 2

Comments

ctacke Feb 25, 2016 at 2:51 AM 
Good call, all. IsIdentity was an early property of the attribute. It was superseded by setting the Entity's KeyScheme. I've updated the example.

rieyfu Aug 14, 2015 at 2:41 AM 
IsIdentity not exist

rembertonius Oct 8, 2012 at 4:11 PM 
IsIdentity not exist ?