Click here to Skip to main content
15,884,012 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone,

I am trying to write a compound join statement using linq-to-sql. I am running into some compile time issues that I can't seem to overcome. Can someone shed some light for me as to what is the best way to proceed with writing linq-to-sql join statements?

Here is what I have so far:
C#
var acc_ped_pos =
                from v in vehicles
                from e in engine
                where v.engine_type == e.engine_type && v.engine_code == e.engine_code
                select e.accelerator_pedal_position;

The compiler says "The type or namespace name "SelectMany" does not exist in the namespace "vehicles" (are you missing an assembly reference)?
The name engine does not exist in the current context.

I have my database set up with a table name engine and vehicles.

Thanks in advance for any assistance!
Posted
Updated 2-Oct-12 7:45am
v2

1 solution

I think, you need to use join[^] command ;)
SQL
var acc_ped_pos = from v in vehicles join e in engine
                where v.engine_type == e.engine_type && v.engine_code == e.engine_code
                select e.accelerator_pedal_position;


Have a look here to: Simple LINQ to SQL in C#[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900