many-to-many

Symfony: ManyToMany table extra columns

亡梦爱人 提交于 2021-02-15 06:49:50
问题 I have a many to many table for User and House , called user_house . Instead of just two columns: user_id and house_id, i want to add 3 more: eg action, created_at, updated_at. How can I do this? I cannot find any relevant docs on this. The following just creates a separate table with two columns in it. class User extends EntityBase { ... /** * @ORM\ManyToMany(targetEntity="AppBundle\Entity\House") */ protected $action; Basically, what I want to achieve is: in the user_house table the

C# Mapping Many To Many

孤街醉人 提交于 2021-02-11 13:10:34
问题 I'm working on a basic application in C# Web. I would like to have 2 objects: - User - Group Here's the class: public class User { public int Id; { get; set; } public String Username { get; set; } public String Password { get; set; } public virtual List<Group> Groups { get; set; } } public class Group{ public int Id { get; set; } public String Name{ get; set; } public virtual List<User> Users { get; set; } } My problem is that when i use this code there's no relation many to many created. I

C# Mapping Many To Many

送分小仙女□ 提交于 2021-02-11 13:09:43
问题 I'm working on a basic application in C# Web. I would like to have 2 objects: - User - Group Here's the class: public class User { public int Id; { get; set; } public String Username { get; set; } public String Password { get; set; } public virtual List<Group> Groups { get; set; } } public class Group{ public int Id { get; set; } public String Name{ get; set; } public virtual List<User> Users { get; set; } } My problem is that when i use this code there's no relation many to many created. I

Remove or edit object name in admin.TabularInline

狂风中的少年 提交于 2021-02-10 06:47:20
问题 My tabular inline in the admin looks like this : How do I get rid of the DateDeCotisation_adherents object phrase ? For bonus points, why are there three empty lines at the bottom ? admin.py class DatesDeCotisationInline(admin.TabularInline): model = DateDeCotisation.adherents.through readonly_fields = ['datedecotisation'] can_delete = False models.py class DateDeCotisation(models.Model): date = models.DateTimeField() adherents = models.ManyToManyField(Adherent, related_name='adherents_du

Insert new record in pivot table with many to many relationship using Entity Framework Core

℡╲_俬逩灬. 提交于 2021-02-10 06:22:35
问题 I am building an application using ASP.NET Core MVC. I am trying to insert a new record with a many-to-many relationship. I have 3 tables Repairs , Parts and RepairParts . How can I insert the RepairId and PartId into the RepairParts table? Does EF Core provide something for this? I searched the documentation but it doesn't mention anything about how to do this. Does Entity Framework do this automatically? (insert to the pivot table) Or do I need to do it manually? An example would help.

Django ManyToMany field through with extra fields does not show on both relations

南笙酒味 提交于 2021-02-09 17:59:47
问题 I have a class Assembly class Assembly(models.Model): room = models.ForeignKey("Room", related_name="assemblies") name = models.CharField(max_length=200) number = models.IntegerField() position = models.CharField(max_length=200, blank=True) components = models.ManyToManyField("material.Component", through="m2m_Assembly_Components") connections = models.ManyToManyField("Assembly", through="Connection") category = models.ForeignKey("Category", default=0) notes = models.TextField(blank=True)

JOOQ pojos with one-to-many and many-to-many relations

情到浓时终转凉″ 提交于 2021-02-08 15:41:45
问题 I am struggling to understand how to handle pojos with one-to-many and many-to-many relationships with JOOQ. I store locations that are created by players (one-to-many relation). A location can hold multiple additional players who may visit it (many-to-many). The database layout comes down to the following: CREATE TABLE IF NOT EXISTS `Player` ( `player-id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `player` BINARY(16) NOT NULL, PRIMARY KEY (`player-id`), UNIQUE INDEX `U_player` (`player` ASC))

SQLAlchemy: Many-to-Many dynamic loading on both sides

只愿长相守 提交于 2021-02-08 10:50:48
问题 Let's say I have the following: association_table = Table('things_stuffs', Base.metadata, autoload=True, extend_existing=True) class Thing(Base): __tablename__ = 'things' __table_args__ = {'autoload': True} class Stuff(Base): __tablename__ = 'stuffs' __table_args__ = ( {'autoload': True} ) things = relationship(Thing, secondary=association_table, backref=backref("stuffs", uselist=False, lazy='dynamic')) Now, if I want to get all the things from a Stuff instance I can do: a_stuff_instance

SQLAlchemy: Many-to-Many dynamic loading on both sides

☆樱花仙子☆ 提交于 2021-02-08 10:48:38
问题 Let's say I have the following: association_table = Table('things_stuffs', Base.metadata, autoload=True, extend_existing=True) class Thing(Base): __tablename__ = 'things' __table_args__ = {'autoload': True} class Stuff(Base): __tablename__ = 'stuffs' __table_args__ = ( {'autoload': True} ) things = relationship(Thing, secondary=association_table, backref=backref("stuffs", uselist=False, lazy='dynamic')) Now, if I want to get all the things from a Stuff instance I can do: a_stuff_instance

Django: How do I create a view to update multiple records on an intermediate model with a Many-to-Many-through relationship?

眉间皱痕 提交于 2021-02-08 10:14:07
问题 I am a beginner to Django, and am creating an RSVP site to handle multiple events and keep track of guests to those events. I have a model for Guest , for Event , and an intermediate model for GuestEvent . I would like a page to loop through every GuestEvent for a Guest and allow me to update the attending , adults , and children fields in GuestEvent . I will never need to create or delete these fields through the front-end. I am currently trying to use the class-based UpdateView, but could