0

는 여기에 내가 람다 쿼리로 변환 할 예입니다 : 당신은 가지고`사용할 수 있습니다sql 제한 쿼리를 linq lambda로 변환하는 방법?

SELECT TOP(5) Pbschedules.s_id, Pbschedules.date, Pbworth2.worth, Pbschedules.pb_id 
FROM Pbschedules INNER JOIN Pbworth2 ON Pbschedules.pb_id = Pbworth2.pb_id 
ORDER BY s_id desc 
+0

(5)' – Pawel

답변

1
var query = database.Pbschedules// your starting point - table in the "from" statement 
    .Join(database.Pbworth2, // the source table of the inner join 
    pbs=> pbs.pb_id,  // Select the primary key (the first part of the "on" clause in an sql "join" statement) 
    worth=> worth.pb_id, // Select the foreign key (the second part of the "on" clause) 
    (pbs, worth) => new { PbsID = pbs.s_id, Worth = worth.worth /*other columns*/ }) // selection 
    .OrderByDescending(x => x.s_id)  
    .Take(5); 
0
var myData = (from valuesPbs in Pbschedules join valuesPbw in Pbworth2 
       on valuesPbs.pb_id equals valuesPbw.pb_id 
       orderby valuesPbs.s_id descending 
       select valuesPbs 
      ).Take(5);