How can i use unioan and nested from linq?

How can i convert to sql to linq . i don't understand nested select query. i need linq codes. Please help me:((((

SELECT @id=id FROM 
    (SELECT id,workorder AS workorderno ,CAST(jobseqno AS int) AS jobseqno FROM dbo.CTask
     UNION ALL
     SELECT id,workorderno,cardno AS jobseqno FROM dbo.NonRoutineCard
     UNION ALL
     SELECT id,workorderno,cardno AS jobseqno FROM dbo.AdditionalWorkCard) a
WHERE RTRIM(workorderno)=RTRIM(@ToNo) AND jobseqno=@ToSeq

LINQ:

  var id = 
  (from task in stock.CTasks select new { task.id, task.workorder, task.jobseqno } )
  .Union(from card in stock.NonRoutineCards select new { card.id, card.workorderno, card.cardno })
  .Union(from card in stock.AdditionalWorkCards select new { card.id, card.workorderno, card.cardno })
  .Where(x => x.workorderno.TrimEnd() == ToNo && x.jobseqno == ToSeq)
  .FirstOrDefault();

if i write above codes error below:

alt text http://i47.tinypic.com/2lax4au.png

Answers


will that suit your needs?

var id = 
  (from task in stock.CTasks select new { task.id, task.workorder, jobseqno= task.jobseqno } )
  .Union(from card in stock.NonRoutineCards select new { card.id, card.workorderno, jobseqno = card.cardno })
  .Union(from card in stock.AdditionalWorkCards select new { card.id, card.workorderno, jobseqno = card.cardno })
  .Where(x => x.workorderno.TrimEnd() == ToNo && x.jobseqno == ToSeq)
  .FirstOrDefault();

Need Your Help

Class dompdf.wrapper does not exist laravel 4.2.0

laravel dompdf

I am trying to use the dompdf package with Lavarel 4.2.0 in my project authored by barryvdh, I tried installing three different versions of this package (0.6*, 0.6.1,0.5.2)

ContinueTrackingWithTouch doesn't get called continuously

ios uicontrol

I am creating a subclass of UIControl and adding to my view controller's view