many-to-many

Deletions in a many-to-many structure

ⅰ亾dé卋堺 提交于 2019-12-09 07:48:54
问题 I just want to check really quickly. Say I have two entities in a data model: Catalog, and Product. They have a many-to-many relationship with each other, and both are required (a Catalog must have at least one Product, and all Products must each belong to at least one Catalog). So if I was to delete a Product, its deletion should be Nullify, of course. But what should the deletion policy be for Catalog? If a Catalog is deleted, not all of its Products necessarily exclusively belong to it. A

How to set a collection-property with FKs?

浪子不回头ぞ 提交于 2019-12-09 06:56:00
问题 I have a Business and a Category model. Each Business has many Categories via an exposed collection ( Category is disregarding the Business entity). Now here is my controller-action: [HttpPost] [ValidateAntiForgeryToken] private ActionResult Save(Business business) { //Context is a lazy-loaded property that returns a reference to the DbContext //It's disposal is taken care of at the controller's Dispose override. foreach (var category in business.Categories) Context.Categories.Attach(category

CRUD Views For Many-Many Relationship, Checkboxes

谁说胖子不能爱 提交于 2019-12-09 06:47:23
问题 I am having a hard time trying to figure out what I need to do to get this to work. I'm learning ASP.NET MVC CodeFirst with EF. If I make a model I can simply add a controller for that model and add scaffolding to create views that automatically take care of CRUD. But now I have two models, Project and Category. They have a many to many relationship and database is designed correctly with the associative table without having to make a separate model for it. The code for the models is this....

Need help with many-to-many relationships in core data for iPhone

我只是一个虾纸丫 提交于 2019-12-09 06:36:44
问题 I have come to a roadblock in my current project. I basically have an app that is much like the Core Data Recipe app... Here is the basic structure I have in my .xcdatamodel Entity: Restaurant String: name Category: category <---- to-many relationship Entity: Category String: name Restaurant: restaurant <---- to-many relationship So basically, a Restaurant can have multiple categories... And there are a const number of predefined Categories.. For example: Restaurant: Name: Chili’s Categories:

EF 4.1 RC Many to many relationship in EF CF

故事扮演 提交于 2019-12-09 06:34:59
问题 I have two entities with many to many relationship like this: class author { public int AuthorID{get;set;} public string Name{get;set;} public virtual ICollection<book> books{get;set;} } class book { public int BookID{get;set;} public string Name{get;set;} public virtual ICollection<author> authors{get;set;} } and I have an intermediate table named Bookauthor defined like this: BookAuthor: int int AuthorID int BookID How to map this using FluentAPI Thanks!! 回答1: This was problematic with EDMX

How to perform a many-to-many filter using ReferenceProperty in Google App Engine?

折月煮酒 提交于 2019-12-08 19:38:29
This is my model, Players and Clubs. As a Club can have many players and a player can have many clubs (in its carrer), I used a many-to-many relationship: class Club(db.Model): name = db.StringProperty() link = db.StringProperty() class Player(db.Model): name = db.StringProperty() link = db.LinkProperty() class ClubHasPlayer(db.Model): club = db.ReferenceProperty(Club, required=True, collection_name='club_players') player = db.ReferenceProperty(Player, required=True, collection_name='player_clubs') number = IntegerProperty() Now, I have a search interface where one can search for all players,

How to handle Many-To-Many In Grails without belongsTo?

故事扮演 提交于 2019-12-08 17:43:53
问题 I need to create a many-to-many relationship in Grails. I have a "Question" domain and a "Tag" domain. A Question can have 0 or more tags. A Tag can have 0 or more Questions. If I put a "hasMany" on each sides, it gives me an error saying I need a "belongTo" somewhere. However, adding a belongsTo means that the owner must exist... Like I said, a Tag could have 0 questions, and a Question could have 0 tags. There is no concept of an owner, it's a many-to-many! What am I supposed to do? 回答1:

Simple example of many-to-many relation using Sequelize

时间秒杀一切 提交于 2019-12-08 15:06:46
问题 I'm trying to build a simple example of many-to-many relation between tables using Sequelize. However, this seems to be way trickier than I expected. This is the code I have currently (the ./db.js file exports the Sequelize connection instance). const Sequelize = require("sequelize"); const sequelize = require("./db"); var Mentee = sequelize.define('mentee', { id: { type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true }, name: { type: Sequelize.STRING } }); var Question = sequelize

Delete Many to Many relationship using Entity Framework

蹲街弑〆低调 提交于 2019-12-08 08:16:15
问题 I've three tables Student (studID, fullName, gender...), Enroll (studID, courseID, date) and Course (courseID,courseName, ...). I used the code below to delete all records from Enroll table with studID 001 where there are about three courses the student signed for. However, it only deletes one record. using(var context = new DBEntities()) { var _stud = (from s in context.Students where s.studID == "001" select s).FirstOrDefault(); var _course = _stud.Courses.FirstOrDefault(); _course.Students

How do I name a many-many table for EF6 and do I need to add special mapping for this?

折月煮酒 提交于 2019-12-08 08:08:00
问题 I am using EF 6 and trying to map a many to many relationship. So far I have: public partial class ObjectiveDetail { public ObjectiveDetail() { this.SubTopics = new List<SubTopic>(); } public int ObjectiveDetailId { get; set; } public string Text { get; set; } public virtual ICollection<SubTopic> SubTopics { get; set; } } public partial class SubTopic { public SubTopic() { this.ObjectiveDetails = new List<ObjectiveDetail>(); } public int SubTopicId { get; set; } public int Number { get; set;