EF and Associations

  • Thread starter Thread starter Etienne-Louis Nicolet
  • Start date Start date
E

Etienne-Louis Nicolet

How can I define an association like the following one in a LINQ to SQL ER
model?

Parent.Column1 -> Child.Column1
Parent.Column2 -> Child.Column2
Child.Column3 = 'xxx'

The appropriate WHERE-clause in an SQL statement would look like:

WHERE
Parent.Column1 = Child.Column1 AND
Parent.Column2 = Child.Column2 AND
Child.Column 3 = 'xxx'

Many thanks for your help,
Etienne-Louis Nicolet
 
Etienne-Louis Nicolet said:
How can I define an association like the following one in a LINQ to SQL ER
model?

Parent.Column1 -> Child.Column1
Parent.Column2 -> Child.Column2
Child.Column3 = 'xxx'

The appropriate WHERE-clause in an SQL statement would look like:

WHERE
Parent.Column1 = Child.Column1 AND
Parent.Column2 = Child.Column2 AND
Child.Column 3 = 'xxx'

Use a 'join' with an anonymous type:
from p in ctx.Parent
join c in ctx.Child on
new { p.Column1, p.Column2} equals
new { c.Column1, c.Column2}
where c.Column3=="xxx"
select ...


FB
 
Back
Top