Reputation: 2372
how can I translate this into LINQ?
Select
Object = case when C.Description='UPLOAD'
then (select SeekName from Uploads where Upload_id= C.Object_id)
else case when C.Description='ACTIVITY'
then (select Name from Activities where Activity_id= C.Object_id)
else (select SUBSTRING(Description,1,10) from Questions where Question_id= C.Object_id)
end
end,
From Contact C
I know that I case use let
to replace case when
. But i need to do a Select
statement in each case when
Upvotes: 0
Views: 1611
Reputation: 13399
from c in context.Contact
select new {obj = c.Description == "UPLOAD" ? c.Uploads.SeekName
: c.Description == "ACTIVITY" ? c.Activity.Name
: c.Question.Description.SubString(1,10)}
If you have the FK set up and it's 1-to-1, else you have to modify the selection like C.Uploads.SeekName
and use some join to find the value
Upvotes: 1