本文整理汇总了C#中Sql.OrderByDescending方法的典型用法代码示例。如果您正苦于以下问题:C# Sql.OrderByDescending方法的具体用法?C# Sql.OrderByDescending怎么用?C# Sql.OrderByDescending使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sql
的用法示例。
在下文中一共展示了Sql.OrderByDescending方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLatestTopicsForMember
/// <summary>
/// Returns an in-memory collection of topics that a given member has participated in
/// </summary>
/// <param name="memberId"></param>
/// <param name="ignoreSpam"></param>
/// <param name="maxCount"></param>
/// <returns></returns>
public IEnumerable<ReadOnlyTopic> GetLatestTopicsForMember(int memberId, bool ignoreSpam = true, int maxCount = 100)
{
var sql = new Sql().Select("TOP " + maxCount + " " +
@"forumTopics.*, u1.[text] as LastReplyAuthorName, u2.[text] as AuthorName,
forumComments.body as commentBody, forumComments.created as commentCreated, forumComments.haschildren,
forumComments.id as commentId, forumComments.isSpam as commentIsSpam, forumComments.memberId as commentMemberId, forumComments.parentCommentId,
forumComments.position, forumComments.score, forumComments.topicId")
.From("forumTopics")
.LeftOuterJoin("forumComments").On("forumTopics.id = forumComments.topicId")
.LeftOuterJoin("umbracoNode u1").On("(forumTopics.latestReplyAuthor = u1.id AND u1.nodeObjectType = '39EB0F98-B348-42A1-8662-E7EB18487560')")
.LeftOuterJoin("umbracoNode u2").On("(forumTopics.memberId = u2.id AND u2.nodeObjectType = '39EB0F98-B348-42A1-8662-E7EB18487560')")
.Where<Topic>(topic => topic.LatestReplyAuthor == memberId || topic.MemberId == memberId);
if (ignoreSpam)
{
sql.Where<Topic>(x => x.IsSpam != true);
sql.Where("forumComments.id IS NULL OR (forumComments.isSpam <> 1)");
}
sql
.OrderByDescending<Topic>(x => x.Updated)
.OrderByDescending<Comment>(comment => comment.Created);
var result = _databaseContext.Database.Fetch<ReadOnlyTopic, ReadOnlyComment, ReadOnlyTopic>(
new TopicCommentRelator().Map,
sql);
return result;
}