如何在Lambda表达式中编写以下sql查询。
select rating from ratingtable where movieId=@movieid and userid=@userid
答案 0 :(得分:1)
你的意思是在LINQ?像这样:
var movieId = 3902; // use valid movie ID
var userId = 5802; // use valid user ID
ratingtable.Where( x => x.movieId==movieId && x.userid==userId )
答案 1 :(得分:0)
var results = from rt in ratingtable.Where(rt => rt.movieId == movie && rt.userid == user)
select rt
对于简单查询,这是一个很好的起点: http://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b