Entity Framework Many To Many CRUD -
I am playing with the unit framework for a POC project. In my database I have
category & lt; ------- Category Products ------- & gt; Product
(where the table model contains a unit.)
I Choose / Insert / Update or at
category product
table is just two from FK to product
and one to category
... EF by default CategoryProduct
unit, instead of manipulating that table to give you the product. Categories
or category Creating / removing relationships will be required by using the Products
collections.
Ie to add a line:
product.Categories.Add (category); // or Category Products. Add (product);
To remove a row:
Products. Categories Remove (Category); //
Contrary to the Visa or the table, to get the rows in that table:
var pc = c to ctx Categories from pc Select new {classID = c.ID, ProductID = p.ID} in the products;
More updates are not understood, because PK (which can not be changed) is all the columns, i.e. none of the columns of the row can be updated, so the row itself Only '
Alex James
Comments
Post a Comment