I must be missing something, when trying to define a HABTM association with 2 of my models. I have a "Product" table, and a "Category" table, and a "ProductsCategories" join table. In SQL Server, I am defining the Relationsh开发者_开发百科ip between the tables on the join table. However, when I create the LINQ to SQL model "Product," I get "Product.ProductCategories -> ProductCategory, ProductsCategory.Product -> Product" Is it possible in asp.net mvc to define a relationship that would give me Product.Categories or Category.Products?
Someone is surely wiser than me on the subject, but I don't know a way of doing this [automatically] if you are using a DBML file to autogenerate your database model. By knowing you can use Product.ProductCategories.Category
and Category.ProductCategories.Product
, you can create partial classes for Product and Category that define properties named Products
and Categories
which return Product.ProductCategories.Category, and Category.ProductCategories.Product.
精彩评论