public abstract class SampleData : DbObjectModel<SampleData>
{
    [MaxLength(50)] public abstract string Name { get; set; }
    public abstract UserRole Role { get; set; }
    public abstract DateTime JoinDate { get; set; }
    public abstract bool Enabled { get; set; }
    public abstract int? NullInt { get; set; }

    public SampleData() {}
    public SampleData(string Name, UserRole Role, DateTime JoinDate, bool Enabled)
        : this(Name, Role, JoinDate, Enabled, null) { }
    public SampleData(string Name, UserRole Role, DateTime JoinDate, bool Enabled,
        int? NullInt)
    {
        this.Name = Name;
        this.Role = Role;
        this.JoinDate = JoinDate;
        this.Enabled = Enabled;
        this.NullInt = NullInt;
    }
}

[DbTable("Sheet1")]
public class BookInfo
{
    [DbColumn("Book Name")] public string BookName;
    public string ISBN;

    public override string ToString()
    {
        return string.Format("Item:{0},{1}", BookName, ISBN);
    }
}

class Program
{
    static void Main(string[] args)
    {
        // first database
        SampleData.Find(null, new OrderBy("Id")).ForEach(delegate(SampleData d)
        {
            Console.WriteLine( d );
        });
        Console.WriteLine();

        // secend database
        DbContext ds = new DbContext(EntryConfig.GetDriver("Excel"));
        IList list = ds.From<BookInfo>().Where(null).Select();
        foreach ( BookInfo bi in list )
        {
            Console.WriteLine( bi );
        }
        Console.ReadLine();
    }
}

Last edited Jul 22, 2007 at 12:11 PM by lifeng, version 1

Comments

No comments yet.