Here is my class:
public class User
{
public int Id { get; set; }
public string Name { get; set; }
public ISet<User> Friends { get; set; }
}
Here is my mapping:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="Test" assembly="test">
<class name="User" table="Users">
...
I am using the Entity framework to create a new order. The order contains a collection of contacts, a many to many relationship. I want to add a reference to an existing contact on the order on creation of the order. Both Order and Contact a Entity Objects.
Order order = new Order();
//set details on order
Contact contact = new ...
I'm trying to build a query with hibernate criteria for the following scenario:
Two entities: Indicator and report (each with their own tables, classes etc.)
an indicator can be used in zero to many reports
a report uses zero to many indicators
therefore, I have an intersection table to store the relationship
the relationship is define...
Wow, it's hard to find a simple explanation to this topic. A simple many-to-many relationship.
Three tables, tableA, tableB and a junction tableA_B.
I know how to set up the relationship, with keys and all, but I get a little confused when time comes to perform INSERT, UPDATE and DELETE queries....
Basically, what I am looking for is...
I have models (simplified example):
class Group(models.Model):
name = models.CharField(max_length = 32)
class Person(models.Model):
group = models.ForeignKey(Group)
class Task(models.Model):
group = models.ForeignKey(Group)
people = models.ManyToManyField(Person)
def save(self, **kwargs):
ppl = Person.objects.all().filt...
Hi folks,
I'm trying to make sure some data is auto-deleted when there's no more references using cascade deletes. I'll explain with a fake database based on Stack Overflow.
I have a Post table. Each post has zero to many Tags.
So it should look like:
Post <-> PostTags <-> Tags
eg.
Post 1 has tags 'A', 'B', 'C' Post 2
has...
Hi folks,
i'm trying to do a simple linq 2 sql many-to-many, insert some data, operation.
here's the stock Northwind model representing a many to many:
Now what i'm trying to do is insert a new order and if the product doesn't exist, then insert that at the same time, within the same transaction. The error i'm getting is:
System.Da...
I have two tables "Group" and "Customer" and of course two entities "Group" and "Customer".
And i have another table which is referencing both "CustomerGroupMember" table.
I use CustomerGroupMember table for many-to-many mapping.
Customer.hbm.xml
<!--Many to many-->
<bag name="CustomerGroups" table="CustomerGroupMember" cascade="a...
I think this should be easy, but it's evading me. I've got a many-to-many relationship between Accounts and Account Groups. An Account can be in zero or more Groups, so I'm using the standard join table.
Accounts
--------
ID
BankName
AcctNumber
Balance
AccountGroups
-------------
ID
GroupName
JoinAccountsGroups
------------------
AID...
So I just started my first rails project yesterday. I had two many-to-many (has_and_belongs_to_many) relationships in my application. I had one between models games and teams and another between models stats and results. This was all working just fine by creating the join table myself with a migration.
I then decided that I did not w...
I have a SQL table like so:
Update: I'm changing the example table as the existing hierarchical nature of the original data (State, Cities, Schools) is overshadowing the fact that a simple relationship is needed between the items.
entities
id name
1 Apple
2 Orange
3 Banana ...
I am a somewhat experienced Rails developer and I thought I would try out ASP.NET's version of MVC. In doing so I also decided to try Linq->Sql...
I am a bit confused about the way Linq->Sql handles joins.
A trivial example of my schema is :
books:
id
title
categories:
id
name
books_categories:
book_id
category_id
Simply dragging...
I am trying to map the following:
public class Person{
...
@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
@JoinTable(name = "person_categories", joinColumns = @JoinColumn(name = "personId"), inverseJoinColumns = @JoinColumn(name = "categoryId"))
private Set<Category> categories
...
}
public class Category ...
I have a couple of models in django which are connected many-to-many. I want to create instances of these models in memory, present them to the user (via custom method-calls inside the view-templates) and if the user is satisfied, save them to the database.
However, if I try to do anything on the model-instances (call rendering methods,...
I have a Resident and can not seem to get the set of SSA's the resident belongs to. I've tried res.ssa_set.all() .ssas_set.all() and .ssa_resident_set.all(). Can't seem to manage it. What's the syntax for a reverse m2m lookup through another table?
EDIT: I'm getting an 'QuerySet as no attribute' error. Erm?
class SSA(models.Model):
...
I've got a many-to-many relationship which I try to fetch eager:
*.CreateCriteria(typeof(Class1))
.SetFetchMode("Class2", FetchMode.Eager)
.SetResultTransformer(new DistinctRootEntityResultTransformer())
.SetFirstResult(20)
.SetMaxResult(10)
.List<Class1>();
I'd like to have rows 20-30 returned, but instead I've got 12-18. Why? Becaus...
I'm trying EF out and I do a lot of filtering based on many to many relationships. For instance I have persons, locations and a personlocation table to link the two. I also have a role and personrole table.
EDIT: Tables:
Person (personid, name)
Personlocation (personid, locationid)
Location (locationid, description)
Personrole (per...
Entity Framework magically interprets the following table structure as a many-to-many relationship.
table foo (int id)
table foo_bar (int foo_id, int bar_id)
table bar (int id)
But if the join table has any additional fields it will instead be interpreted as two one-to-many relationships.
I am using a database in which the join table...
I need to retrieve institution name by going through an intermediate table. My view gets all the values except this one or at least it is not displaying in the template. Can someone please help with either revising my view or template statement?
http://dpaste.com/122204/
Thank you,
May
...
MODEL:
class Pathology(models.Model):
pathology = models.CharField(max_length=100)
class Publication(models.Model):
pubtitle = models.TextField()
class Pathpubcombo(models.Model):
pathology = models.ForeignKey(Pathology)
publication = models.ForeignKey(Publication)
List of pathology sent to HTML template as drop dow...