With clause and column matching

15 views
Skip to first unread message

Tim Bourguignon

unread,
May 15, 2013, 10:49:52 AM5/15/13
to simpl...@googlegroups.com
Hi everyone,

I cannot manage to wrap my head around this one.

I have two SQL tables "EntityValues" and "PropertyValue".

The "PropertyValue" table has two columns containing foreign keys to the "EntityValues" but with different meanings: 
  • PropertyValue.EntityValue means that the entity has a property (inverse relation)
  • PropertyValue.ReferencedEntityValue means that the property actually references another entity
When I try a very broad query like the following, Simple.Data joins the data using the ReferencedEntityValue column and not the EntityValue as I would like it to:

> db.EntityValues.All().With(db.PropertyValues)

Do you have any hints on how to solve this?

Thanks,
Tim

Mark Rendle

unread,
May 15, 2013, 10:54:40 AM5/15/13
to Simple.Data
Simple.Data will follow the referential integrity in the DB. You can use an explicit join to override this.


Cheers,
Mark

Mark Rendle
Founder & CEO
Oort Corporation
Makers of Zudio


--
You received this message because you are subscribed to the Google Groups "Simple.Data" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simpledata+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Tim Bourguignon

unread,
May 16, 2013, 3:59:37 AM5/16/13
to simpl...@googlegroups.com
Hi Mark, thanks for your answer!

I might be misunderstanding the concept of referential integrity then because that's exactly what I expected.

The two columns in the PropertyValue table contain foreign keys, but one column is nullable and the other one is not. The one that Simple.Data is automagically taking is the nullable one... doesn't that go against the referential integrity?

Thanks,
Tim

Mark Rendle

unread,
May 16, 2013, 4:36:32 AM5/16/13
to Simple. Data

Ah. Simple.Data will just take the first key it finds, so the nullable one is obviously bring returned first.

Tim Bourguignon

unread,
May 16, 2013, 4:39:46 AM5/16/13
to simpl...@googlegroups.com
Damn. I'll go the explicit joins way then ;)

Thanks a bunch!
Reply all
Reply to author
Forward
0 new messages