我正在使用LINQ to SQL和LINQ动态在哪里和顺序.
我想将下面的代码(ASP)转换为C#.net.
function getTestimonialList(statusCd)
sWhere = ""
if statusCd <> "" then
sWhere = " where status='" & statusCd & "'"
end if
sqlStr="select * from testimonial" & sWhere & " order by case when status = 'P' then 1 when status = 'A' then 2 else 3 end, dateadded desc"
set rs=getResult(sqlStr)
set getTestimonialList=rs
end function
Run Code Online (Sandbox Code Playgroud)
这是我的查询:
var TestimonialList = from p in MainModelDB.Testimonials
where String.IsNullOrEmpty(statusCd)?"1=1":p.status== statusCd
orderby p.status == 'P' ? 1 : (p.status == 'A' …Run Code Online (Sandbox Code Playgroud)