关于linq to sql多表,笔者将在此文中作出详细的阐述,希望能给大家带来帮助。
在讲述linq to sql多表之前,先看看生成的两个实体类的构造函数:
1。linq to sql多表之Categories类
public Categories()
{
this._Products = new EntitySet<Products>
(new Action<Products>(this.attach_Products),
new Action<Products>(this.detach_Products));
OnCreated();
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
2。linq to sql多表之Products类
public Products()
{
this._Order_Details = new EntitySet<Order_Details>
(new Action<Order_Details>(this.attach_Order_Details),
new Action<Order_Details>(this.detach_Order_Details));
this._Categories = default(EntityRef<Categories>);
this._Suppliers = default(EntityRef<Suppliers>);
OnCreated();
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
比较生成的构造函数,分别用了EntitySet
而你在查询一个产品实体而有要得到产品所属分类直接得到linq to sql多表。
p=new products();
p.categories.categories.categoriesnameategoryNamentityRef
- 1.
- 2.
以上就是对linq to sql多表的详细阐述。
【编辑推荐】