Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to convert the following SQL to LINQ:

SELECT   'Employer' note_type, TRUNC (dated) dated, note
    FROM PHSP.employer_note
   WHERE employer = :employer AND popup = 'Y'
UNION
SELECT   'Employee', TRUNC (dated), note
    FROM PHSP.employee_note
   WHERE employee = :employee AND popup = 'Y'


It checks if there is notes for the employer_note table then concatenates notes from the employee_note table.

This is what I did:

(from e in EmployerNotes
  where e.Employer == 37471 &&
  e.Popup == "Y"
  select new { Dated = e.Dated, Note = e.Note, note_type= "Employer"})
.Concat(
from n in EmployeeNotes
  where n.Employee == 34715 &&
  n.Popup == "Y"
  select new { Dated = n.Dated, Note = n.Note, note_type= "Employee"})


For the specific employee there is notes in both and the notes are shown from both, but the Type always says "Employer" even though it should be "Employer for first row and "Employee" for second row.

Is there something else needed so the types will show correctly depending on what table they were selected from?

Thank you.
Posted
Updated 15-Dec-10 5:38am
v2

1 solution

Hi Have a look on these
1) Linq-union-operator[^]
2) Linq-union[^]
3) 101 LINQ Samples[^]
 
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