Author |
Share Topic Topic Search Topic Options
|
Vonzkie
Senior Member
Joined: 01-Aug-2011
Location: PH
Posts: 133
|
Post Options
Quote Reply
Topic: Custom Association with multiple criteria Posted: 19-Apr-2012 at 2:44am |
Hi,
How can I create a custom association in Devforce that have multiple criteria?
E.g:
Customer CustomerID Name LocationID
Invoice InvoiceID CustomerID Description InvoiceLocationID
I want to have a one to many relationship with Customer and Invoice but the criteria would be:
Customer Invoice CustomerID = CustomerID LocationID = LocationID
How can I do that?
Thanks, Von
|
|
Vonzkie
Senior Member
Joined: 01-Aug-2011
Location: PH
Posts: 133
|
Post Options
Quote Reply
Posted: 19-Apr-2012 at 2:45am |
Correction:
Customer Invoice CustomerID = CustomerID LocationID = InvoiceLocationID
|
|
sbelini
IdeaBlade
Joined: 13-Aug-2010
Location: Oakland
Posts: 786
|
Post Options
Quote Reply
Posted: 19-Apr-2012 at 12:22pm |
Hi Vonzkie, Are you talking about Code First? If that's the case you must set the order of the PK when working with composite keys: Column("CustomerID", Order=0)] You can check our Code First samples in the DevForce Resource Center for more details in creating CodeFirst Entities/Navigation Properties. Regards, Silvio.
|
|
Vonzkie
Senior Member
Joined: 01-Aug-2011
Location: PH
Posts: 133
|
Post Options
Quote Reply
Posted: 19-Apr-2012 at 4:14pm |
Hi,
I'll try to look at it. :) How about not Code First?
Thanks, VOn
|
|
sbelini
IdeaBlade
Joined: 13-Aug-2010
Location: Oakland
Posts: 786
|
Post Options
Quote Reply
Posted: 19-Apr-2012 at 4:27pm |
In model first you mark the properties as Entity Keys and set the Referential Constraint accordingly. Silvio.
|
|
Vonzkie
Senior Member
Joined: 01-Aug-2011
Location: PH
Posts: 133
|
Post Options
Quote Reply
Posted: 22-Apr-2012 at 11:31pm |
Hi Silvio,
That works for us. However, since let's say for example I have my table marked 2 of its column as Entity Key and tried to associate it again with another table but I don't need the criteria being map to the other column. How would I do it?
Thanks, Von
|
|
sbelini
IdeaBlade
Joined: 13-Aug-2010
Location: Oakland
Posts: 786
|
Post Options
Quote Reply
Posted: 23-Apr-2012 at 10:09am |
Von, Not sure I understand the question. You are trying to associate 2 tables, but don't want to use the PK_FK association? Please clarify. Silvio.
|
|
Vonzkie
Senior Member
Joined: 01-Aug-2011
Location: PH
Posts: 133
|
Post Options
Quote Reply
Posted: 23-Apr-2012 at 5:45pm |
Hi Silvio,
Here's the original problem that we solved.
Customer CustomerID Name LocationID
Invoice InvoiceID CustomerID Description InvoiceLocationID
I want to have a one to many relationship with Customer and Invoice but the criteria would be:
Customer Invoice CustomerID = CustomerID LocationID = LocationID
Now, what about adding another table and link it with Customer such as CustomerDetails
CustomerDetails DetailID Description CustomerID
How do I associate this to Customer by bypassing the LocationID because I don't need it in this association.
Thanks, Von
|
|
sbelini
IdeaBlade
Joined: 13-Aug-2010
Location: Oakland
Posts: 786
|
Post Options
Quote Reply
Posted: 24-Apr-2012 at 11:50am |
Von, You might want to take a look at the Code First documentation on details on how to accomplish your objective (if possible): I hope this helps. Regards, Silvio.
|
|
Vonzkie
Senior Member
Joined: 01-Aug-2011
Location: PH
Posts: 133
|
Post Options
Quote Reply
Posted: 25-Apr-2012 at 1:35am |
Hi Silvio,
Would that be possible with Database First Design? Are there some workarounds?
THanks, Von
|
|
sbelini
IdeaBlade
Joined: 13-Aug-2010
Location: Oakland
Posts: 786
|
Post Options
Quote Reply
Posted: 26-Apr-2012 at 2:50pm |
Hi Von, You won't be able to create an association where the FK is part of a composite key. Since it's just a FK you better off simply adding it to your CustomerDetails entity. Since this is more of a design question I think you'd benefit more from our Professional Services Team assistance. Let me know if this interests you, so I can have someone get in touch with you in this regard. Silvio.
|
|