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