Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL LINQ
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:
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 2-Oct-12 8:44am
Edited 2-Oct-12 8:45am
JF201553.3K
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I think, you need to use join[^] command Wink | ;)
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#[^]
  Permalink  

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

  Print Answers RSS
0 George Jonsson 215
1 Kornfeld Eliyahu Peter 169
2 OriginalGriff 120
3 PIEBALDconsult 110
4 BillWoodruff 85
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 2 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100