public abstract class User : DbObjectModel<User>
{
    public abstract string Name { get; set; }
    public abstract int Age { get; set; }
    public abstract bool Gender { get; set; }
    [AllowNull] public abstract DateTime Birthday { get; set; }

    public User() { }
    public User(string Name, int Age, bool Gender, DateTime Birthday)
    {
        this.Name = Name;
        this.Age = Age;
        this.Gender = Gender;
        this.Birthday = Birthday;
    }
}

class Program
{
    static void Main(string[] args)
    {
        // Find Sytex
        List<User> ls = User.Find(CK.K["Age"] > 15 && CK.K["Gender"] == true);
        ls = User.Find(CK.K["Age"] > 15, new OrderBy("Id"));
        // Complex Query
        ls = DbEntry
        	.From<User>()
        	.Where(CK.K["Age"] > 15 && CK.K["Gender"] == true)
        	.OrderBy((DESC)"Id")
        	.Range(11, 20)
        	.Select();
        // Compose Conditions
        WhereCondition c = null;
        c &= CK.K["Age"] > 15;
        c &= CK.K["Gender"] == true;
        c |= CK.K["Birthday"] > DateTime.Parse("1982-11-4");
        c &= CK.K["Birthday"] != null;
        ls = User.Find(c);
    }
}

Last edited Jul 22, 2007 at 10:30 AM by lifeng, version 4

Comments

No comments yet.