Orderby desc在Neo4jClient中具有多个属性

Orderby desc在Neo4jClient中具有多个属性,neo4j,neo4jclient,Neo4j,Neo4jclient,假设我有4张照片,我想返回一个列表,第一个按Rating desc排序,第二个按Rating Scont desc排序。下面的cypher查询给出了正确的结果: MATCH (n:`Photo`) WHERE n.RatingsCount > 0 RETURN n.Rating, n.RatingsCount ORDER BY n.Rating DESC, n.RatingsCount DESC LIMIT 20 Id 1-额定值9-额定值1 Id 3-等级7-等级2 Id 2-额定值7

假设我有4张照片,我想返回一个列表,第一个按Rating desc排序,第二个按Rating Scont desc排序。下面的cypher查询给出了正确的结果:

MATCH (n:`Photo`) WHERE n.RatingsCount > 0 RETURN n.Rating, n.RatingsCount ORDER BY n.Rating DESC, n.RatingsCount DESC LIMIT 20
Id 1-额定值9-额定值1

Id 3-等级7-等级2

Id 2-额定值7-额定值1

Id 4-额定值2-额定值1

不幸的是,我无法将其转换为Neo4jClient。下面的查询为我提供了一个按评级升序和评级降序排列的照片列表:

var query = await graphClient.Cypher
            .Match("(photo:Photo)")
            .Where((PhotoEntity photo) => photo.RatingsCount > 0);
            .ReturnDistinct((photo) => new
            {
                Photo = photo.As<PhotoEntity>()
            })
            .OrderByDescending("photo.Rating", "photo.RatingsCount")
            .Limit(20)
            .ResultsAsync;
var query=wait graphClient.Cypher
.Match(“(照片:照片)”)
其中((照片实体照片)=>photo.ratingscont>0);
.ReturnDistinct((照片)=>新
{
Photo=Photo.As()
})
.OrderByDescending(“photo.Rating”、“photo.RatingsCount”)
.限额(20)
.ResultsAsync;
Id 4-额定值2-额定值1

Id 3-等级7-等级2

Id 2-额定值7-额定值1

Id 1-额定值9-额定值1

如果我改变评级和评级的顺序,我会得到一个更奇怪的顺序:)有任何线索表明我做错了什么吗

var query = await graphClient.Cypher
                .Match("(photo:Photo)")
                .Where((PhotoEntity photo) => photo.RatingsCount > 0);
                .ReturnDistinct((photo) => new
                {
                    Photo = photo.As<PhotoEntity>()
                })
                .OrderByDescending("photo.RatingsCount", "photo.Rating")
                .Limit(20)
                .ResultsAsync;
var query=wait graphClient.Cypher
.Match(“(照片:照片)”)
其中((照片实体照片)=>photo.ratingscont>0);
.ReturnDistinct((照片)=>新
{
Photo=Photo.As()
})
.OrderByDescending(“照片评级”和“照片评级”)
.限额(20)
.ResultsAsync;
Id 1-额定值9-额定值1

Id 2-额定值7-额定值1

Id 4-额定值2-额定值1


Id 3-Rating 7-RatingScont 2

我查看了Neo4jClient的源代码和
OrderByDescending()
简单地
string.join()s
它的参数带有逗号,并在末尾添加了'DESC'。换句话说:除了最后一个属性外,它对每个属性的ASC进行排序。我同意这是违反直觉的,所以我倾向于避免

您可以改用
OrderBy()

OrderBy("photo.RatingsCount DESC, photo.Rating DESC")

啊,当然,下次在这里提问之前,我将检查Neo4jClient的源代码:)我实际上尝试了这种方法,但使用小写的desc而不是desc,这给了我一个例外。在我的例子中,我想先按评级排序,但OrderBy(“photo.rating DESC,photo.rating scont DESC”)非常有魅力,谢谢!!