linq to sql多表的淺析
關(guān)于linq to sql多表,筆者將在此文中作出詳細的闡述,希望能給大家?guī)韼椭?/P>
在講述linq to sql多表之前,先看看生成的兩個實體類的構(gòu)造函數(shù):
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();
- }
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();
- }
比較生成的構(gòu)造函數(shù),分別用了EntitySet
而你在查詢一個產(chǎn)品實體而有要得到產(chǎn)品所屬分類直接得到linq to sql多表。
- p=new products();
- p.categories.categories.categoriesnameategoryNamentityRef
以上就是對linq to sql多表的詳細闡述。
【編輯推薦】