convert into linq query

Posted by Oswaldlily under ASP.NET on 9/30/2011 | Points: 10 | Views : 1329 | Status : [Member] | Replies : 2
Select Column1 as id ,case when column2='' then column1+ ':' + CAST(column3 as varchar(max))
else column3 end as desc
from tablename
where type= @type

This query in storedProcedure.How to change to linq




Responses

Posted by: Jayakumars on: 10/1/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

First Post Your sp and table script and your requirements what do u need output.

Mark as Answer if its helpful to you

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Niladri.biswas on: 10/2/2011 [Member] Platinum | Points: 25

Up
0
Down
Try the below

string strType=<insert value>


var results =
from record in tablename.AsEnumerable()
where record.Field<string>("type") == strType
select new
{
Id = record.Field<string>("Column1"),
Desc = string.IsNullOrEmpty(record.Field<string>("Column2"))
? string.concat(
record.Field<string>("Column1"),
":",
record.Field<string>("Column3")
)
: record.Field<string>("Column3")
};






Hope this helps

Best Regards,
Niladri Biswas

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response