2009-12-20 91 views
0

當我嘗試用我的模型中的2個定義HABTM關聯時,我必須缺少一些東西。我有一個「Product」表,一個「Category」表和一個「ProductsCategories」連接表。在SQL Server中,我正在定義連接表上的表之間的關係。但是,當我創建LINQ to SQL模型「產品」時,我得到「Product.ProductCategories - > ProductCategory,ProductsCategory.Product - > Product」是否有可能在asp.net mvc中定義一個關係,該關係會給我Product.Categories或Category.Products?ASP.Net MVC HABTM Association

回答

1

有人肯定比我更聰明的主題,但我不知道如何使用DBML文件自動生成數據庫模型[自動]。通過知道可以使用Product.ProductCategories.CategoryCategory.ProductCategories.Product,可以爲產品和類別創建部分類,以定義名爲ProductsCategories的屬性,它們返回Product.ProductCategories.Category和Category.ProductCategories.Product。

+0

一個很好的解決方法... – 2009-12-20 16:02:55