Joining an entity and a typedview

Posts   
 
    
mihies avatar
mihies
User
Posts: 800
Joined: 29-Jan-2006
# Posted on: 10-Apr-2012 09:42:19   

I have an entity A and a typedview B. Both have same fields (F1, F2, F3) which I would like to use to join them. Fields are not a key in both tables. I can't map B into an entity because it doesn't have a PK.

So, I'd like something like (plus apply a filter on it)

SELECT A.*,  B.* where A.F1 = B.F1 AND A.F2 = B.F2 AND A.F3 = B.F3

Is it even possible without modifying database schema?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 10-Apr-2012 10:51:06   

Database approach: Create a view that joins them both.

Designer approach: The view should be amapped to an entity, so either pick any field and set it as the PK. It won't make a difference which field, as long as you are using it in a Read-Only fashion. Then you can create a custom relation in code, that you can use to join between them.

mihies avatar
mihies
User
Posts: 800
Joined: 29-Jan-2006
# Posted on: 10-Apr-2012 11:18:28   

Hi Walaa,

Creating a view is out of the question (can't touch DB schema) while the other option has an annoying collateral issue - it will annoy me upon schema refresh.

Thanks anyway, Miha

mihies avatar
mihies
User
Posts: 800
Joined: 29-Jan-2006
# Posted on: 10-Apr-2012 11:20:27   

I guess that there is a third option of copying the database schema, tweak it, and build entities upon that one.

aaaargh this poorly built database schemas!