我有这段代码
ORDER BY c.SenderId
我应该如何添加“按顺序排列”:
type="text/css"
答案 0 :(得分:0)
在其末尾添加OrderBy
:
var chats = (from c in _entities.Chats
where c.SenderId == userId || c.ReceiverId == userId
select new ChatList()
{
Logo = c.SenderId != userId ? c.Company.LogoUrl:c.Company1.LogoUrl,
Name = c.SenderId != userId? c.Company.CompanyPersonName:c.Company1.CompanyPersonName,
UserId = c.SenderId!=userId ?c.Company.CompanyId : c.Company1.CompanyId
}
).Distinct().OrderBy(x => x.UserId)