How do I select relationships via LINQPad?

I have a simple table structure

Images(image_id, image_library_id,...)

Links(link_id, image_id, link_component_code...)

      

I am trying to execute a simple query using LINQ

var q = from i in Images where i.Link.link_component_code = "x" select i;

      

However intellisense in LINQPad does not provide a Link object in

where i.Link.link_component_code

      

instead, I only get the References object, which is an EntitySet, and does not navigate to the list of table fields like Add, Select, Where, etc.

However, if I do it the other way around

var q = from l in Links where l.Image.image_library_id = 1234 select l;

      

It works as expected

What is this EntitySet and where am I going wrong?

0


a source to share


2 answers


How your relationship is set up, each image is 0 or more links (many links). The Links property of an image is a programmed set of related link records.

Try this where the suggestion



where i.Links.Any(link => link.link_component_code == "x")

      

+1


a source


Is there more than one image per image? If not, limit the image_id field in the link table to be unique. Then you should get the expected results.



0


a source







All Articles