Kalpa Wijesooriya
Kalpa Wijesooriya

Reputation: 45

ASP.NET MVC Entity Framework - Linq query with order by

issue_line_person table

I have data table call issue_line_person (above picture). I want to retrieve set of rows which are equal to specific line_id and issue_id, with ascending order according to the levelOfResponsibility.

This is the SQL query for that.

SELECT * 
FROM issue_line_person 
WHERE line_id = " + line_line_id + " AND issue_id = " + issueId + " 
ORDER BY levelOfResponsibility

How to do that using Entity Framework and a Linq method?

Upvotes: 0

Views: 671

Answers (1)

Ivaylo Stoev
Ivaylo Stoev

Reputation: 487

Assuming you have an entity "Issue_Line_Person" in your EF model without properties in child entities.

var result = Issue_Line_Person.Where(_=>_.line_id == LINEID && _.issue_id == ISSUEID).OrderBy(_=>_.levelOfResponsibility).ToList()

Upvotes: 1

Related Questions