C#3。0 LINQ 操作符
2013-09-29 16:46
155 查看
Table 类:
public class Customer
{
[Column(IsPrimaryKey=true)] public int ID;
[Column] public string Name;
[Association (OtherKey="CustomerID")]
public EntitySet<Purchase> Purchases = new EntitySet<Purchase>();
}
public class Purchase
{
[Column(IsPrimaryKey=true)] public int ID;
[Column] public int CustomerID;
[Column] public string Description;
[Column] public decimal Price;
[Column] public DateTime Date;
EntityRef<Customer> custRef;
[Association (Storage="custRef",ThisKey="CustomerID",IsForeignKey=true)]
public Customer Customer
{
get { return custRef.Entity; } set { custRef.Entity = value; }
}
}
public class DemoDataContext : DataContext { public DemoDataContext (string cxString) : base (cxString) {} public Table<Customer> Customers { get { return GetTable<Customer>(); } } public Table<Purchase> Purchases { get { return GetTable<Purchase>(); } } }