Neo4j-如何使用c#client cypher的WITH子句
我试图在C#neo4j客户机中使用WITH子句获得结果。Neo4j-如何使用c#client cypher的WITH子句,c#,neo4jclient,C#,Neo4jclient,我试图在C#neo4j客户机中使用WITH子句获得结果。 因为我是neo4j的新手,所以我不知道如何在C#中获得结果 请帮我提建议 MATCH (cs:CrawlerInfo) WITH cs, SIZE((cs)-[:CONTAINS]->()) as TotalResult RETURN cs.CrawlerName,cs.Keyword,cs.SearchType,toint(TotalResult),cs.CrawlerInfoDate order by toint(cs.Cra
因为我是neo4j的新手,所以我不知道如何在C#中获得结果
请帮我提建议
MATCH (cs:CrawlerInfo)
WITH cs, SIZE((cs)-[:CONTAINS]->()) as TotalResult
RETURN
cs.CrawlerName,cs.Keyword,cs.SearchType,toint(TotalResult),cs.CrawlerInfoDate
order by toint(cs.CrawlerId) desc
在
Neo4jClient
中,直接翻译是关键,应该可以通过API发现
//gc = GraphClient instance
//CrawlerInfo is a class
gc.Cypher
.Match("(cs:CrawlerInfo)")
.With("cs, SIZE( (cs)-[:CONTAINS]->() ) as TotalResult")
.Return((cs, TotalResult) => new
{
CrawlerName = cs.As<CrawlerInfo>().CrawlerName,
Keyword = cs.As<CrawlerInfo>().Keyword,
SearchType = cs.As<CrawlerInfo>().SearchType,
CrawlerInfoDate = cs.As<CrawlerInfo>().CrawlerInfoDate,
Size = Return.As<int>("toint(TotalResult)")
})
.OrderByDescending("toint(cs.CrawlerId)");
那么您也不需要(不应该!)执行toint
,这意味着您可以执行以下操作:
gc.Cypher
.Match("(cs:CrawlerInfo)")
.With("cs, SIZE( (cs)-[:CONTAINS]->() ) as TotalResult")
.Return((cs, TotalResult) => new
{
CrawlerName = cs.As<CrawlerInfo>().CrawlerName,
Keyword = cs.As<CrawlerInfo>().Keyword,
SearchType = cs.As<CrawlerInfo>().SearchType,
CrawlerInfoDate = cs.As<CrawlerInfo>().CrawlerInfoDate,
Size = Return.As<int>("TotalResult")
})
.OrderByDescending("cs.CrawlerId");
其中,CrawlerInfo
定义为:
public class CrawlerInfo
{
public int CrawlerId { get; set;}
public string CrawlerName { get; set; }
public string Keyword { get; set; }
public string SearchType { get; set; }
public string CrawlerInfoDate { get; set;}
}
您使用的是
Neo4jClient
还是Neo4j驱动程序
?
gc.Cypher
.Match("(cs:CrawlerInfo)")
.With("cs, SIZE((cs)-[:CONTAINS]->()) as TotalResult")
.Return((cs, TotalResult) => new
{
CrawlerInfo = cs.As<CrawlerInfo>(),
Size = Return.As<int>("TotalResult")
})
.OrderByDescending("cs.CrawlerId");
public class CrawlerInfo
{
public int CrawlerId { get; set;}
public string CrawlerName { get; set; }
public string Keyword { get; set; }
public string SearchType { get; set; }
public string CrawlerInfoDate { get; set;}
}