更新时间:2023-02-07 13:49:04
我认为您不能将条件放入较大的查询中,但是您可以将其分成另一个C#语句,如下所示:>
I don't think you can put a condition into the larger query, but what you could do is separate it into another C# statement, like this:
// Common code:
var hosters = from e in context.Hosters_HostingProviderDetail
where e.ActiveStatusID == pendingStateId;
// The difference between ASC and DESC:
hosters = (sortOrder == SortOrder.ASC ? hosters.OrderBy(e => e.HostingProviderName) : hosters.OrderByDescending(e => e.HostingProviderName));
// More common code:
returnList = hosters.ToList<Hosters_HostingProviderDetail>();