Here are a couple quick examples:

Mapped class to Employees table:

        private sealed class Employee
        {
            public Guid ID
            {
                get;
                set;
            }

            public string Name
            {
                get;
                set;
            }

            public int Number
            {
                get;
                set;
            }

            public override string ToString()
            {
                return string.Format("ID: {0} Name: {1} Number: {2}", ID, Name, Number);
            }
        }

        private sealed class SweetDatabase : Database<SweetDatabase>
        {
            public SweetDatabase(ConnectionParameters parameters)
                : base(parameters)
            { }

            [Table(Name = "Employees")]
            [Column(IsPrimaryKey = true, MemberName = "ID")]
            [Column(MemberName = "Name")]
            [Column(MemberName = "Number")]
            public Table<Employee> Employees
            {
                get
                {
                    return GetTable<Employee>("Employees");
                }
            }
        }


Code to print out all employees:

                using (SweetDatabase database = new SweetDatabase(new ConnectionParameters
                    {
                        DataSource = "(local)",
                        Database = "Test",
                        Username = "sa",
                        Password = "",
                    }))
                {
                    foreach (Employee employee in database.Employees)
                    {
                        Console.WriteLine(employee);
                    } 
                }

Last edited Dec 30, 2009 at 1:32 PM by jonathanpeppers, version 10

Comments

No comments yet.