one-to-many

CoreData performance: predicate on more to-many relationships

孤街浪徒 提交于 2019-12-11 02:43:01
问题 Using SQL data store, I have a model like this: Category <-->> Item Collection <-->> Item Brand <-->> Item Every left-side entity has a to-many relationship named items to the Item entity. Each one is the inverse of to-one Item relationships category , collection and brand respectively. I want to fetch all Brand objects with at least one Item in relation with a particular Collection AND a Category. In natural language, I want all the brands of items with particular category and a particular

Filtering on reverse relations

淺唱寂寞╮ 提交于 2019-12-11 01:38:30
问题 I have tastypie and Django set up, and they work well, I can filter, and patch objects via HTTP. Now I want to try filtering my results on a reverse relationship and I am having trouble getting it working. So my Django models are like so, each library object has a multiplex index, and each multiplex index may have multiple libraries it is used with : class MultiplexIndex(models.Model): multiplex_index_name = models.CharField(max_length = 100, unique=True ) multiplex_index_seq = models

Fluent nhibernate One-to-Many when Inverse is used Child table's Foreign key is null

放肆的年华 提交于 2019-12-11 00:55:22
问题 I have a parent and child table and entites are created and mapped using one to many relation ship. On one to many side when i use Inverse() then the child table's foreign key value is inserted as null. public class TableA { public virtual long ID { get; set; } public virtual string Name { get; set; } public virtual IList<TableB> TableB { get; set; } } public class TableB { public virtual long ID { get; set; } public virtual string Name { get; set; } public virtual TableA TableA { get; set; }

Generating Checkbox Lists with MVC3 using a complex viewmodel and a cross table with Linq to SQL

雨燕双飞 提交于 2019-12-11 00:45:04
问题 I've inherited my first MVC project and it involves using MVC3 on top of Linq to SQL. I've been trying to find a way to generate a check box list based on a many to many relationship involving a cross table. I have a systemFailureType table that maps to a SystemFailureProblem table via a cross table. Here is my designer layout for the tables: And here are my models: [MetadataType(typeof(SystemFailureProblemMetadata))] public partial class SystemFailureProblem { private class

play framework 2 ebean @manytoone Column specified twice

安稳与你 提交于 2019-12-10 23:37:30
问题 I'm running to some problems with ebean (using play framework 2 version 2.2.1) I have two classes: my graph class: public class Graph extends Model { @Id @Column(name="id") private String id; @Column(name="type") private String type; @OneToMany(mappedBy="valGraph", cascade=CascadeType.ALL) private List<Val> valItems; and my value class (with Val.graphId foreign key Graph.id): public class Val extends Model @Id @Column(name="valId") private String valId; @Id @Column(name="graphId") private

getting the sum of all instances of Entity B from a given instance of Entity A

孤街浪徒 提交于 2019-12-10 23:32:34
问题 I have a to-many relationship between Entity A and Entity B (iOS Core Data app). I need to get the sum of the NSDecimalNumber attribute of all instances of Entity B from a given instance of Entity A. Does anyone have a tutorial or example of this? 回答1: You would use the @sum collection operator thusly: NSNumber *theSum=[ObjectA.objectBs valueForKey:@"@sum.numericalAttribute"]; 来源: https://stackoverflow.com/questions/5251255/getting-the-sum-of-all-instances-of-entity-b-from-a-given-instance-of

MySQL struggling with query in one to many relationship matching multiple conditions

纵然是瞬间 提交于 2019-12-10 20:45:06
问题 I have two tables which are set out roughly as follows: products product_attributes ================== ======================================== | id | name | | id | product_id | attribute | value | ================== ======================================== | 1 | product 1 | | 1 | 1 | size | big | | 2 | product 2 | | 2 | 1 | colour | red | | 3 | product 3 | | 3 | 2 | size | medium | | 3 | product 3 | | 4 | 2 | age_range | 3-5 | | .. | ... | | 5 | 2 | colour | blue | ================== | 6 | 3

One to Many Relationship with Join Table using EF Code First

只愿长相守 提交于 2019-12-10 17:16:11
问题 I have a question about how to configure the one to many relationship with a join table using Code First fluent API. I have a Company, Contact Object both share a common Address Object like below Class Address { public int AddressId ..... } Class Company { public int CompanyId ...... public virtual ICollection<Address> Address } Class Contact { public int ContactID ....... public virtual ICollection<Address> Address } My expected DB structure would be Company Table CompanyId PK NOT NULL .....

Select mysql data with where clause in 2 tables

倾然丶 夕夏残阳落幕 提交于 2019-12-10 15:52:58
问题 I have 2 mysql tables like in the example below: CARS Id CAR NAME AGE 1 Ford 2 years 2 AUDI 1 years 3 Ford 2 years OPTIONS Id id_car option 1 1 ESP 2 2 ABS 3 3 ABS 4 3 ESP And I need to select all cars of 2 years old wich have ABS AND ESP . So it should return in this example: 3 Ford If you have any idea... Thanks 回答1: The group by/having will ensure that the car has both of the desired features. select c.id, c.name from cars c inner join options o on c.id = o.id_car and o.option in ('ABS',

Doctrine2 OneToMany - ManyToOne returns empty collection with database ok

心已入冬 提交于 2019-12-10 13:44:29
问题 I have many relations of this type, but I can't see why this one is not working. I have a Delegation and a Promotion entities: Delegation Promotion /** * Company\CBundle\Entity\Promotion * * @ORM\Entity * @DoctrineAssert\UniqueEntity("promotionCode") */ class Promotion { const REGISTER_DAYS = 30; const REGISTER_DISCOUNT = 100; /** * @var integer $id * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * @ORM\Column(name=