我有一个原始查询,我想转换为fluent接口。
var assetExistsQuery = new Query(
@"MATCH (tenant:Tenant)-[r]->(user:User {userName: $userName})
WHERE tenant.status = $status AND tenant.userId = $userId
RETURN user,tenant", new
{
userId = params.UserId,
status = params.TenantStatus,
userName = params.UserName,
});
到目前为止,就是这样
var result = await CypherQuery
.Match("(tenant:Tenant)-[r]->(user:User)")
.Where((Tenant tenant, User user) => tenant.Status == params.Status && tenant.UserId == params.UserId && user.UserName == params.UserName)
.Return<Tenant>("tenant").ResultsAsync;
但是我收到这个错误
System.MissingMethodException: 'Method not found: 'System.Threading.Tasks.Task`1<!!0> Neo4j.Driver.IAsyncSession.ReadTransactionAsync(System.Func`2<Neo4j.Driver.IAsyncTransaction,System.Threading.Tasks.Task`1<!!0>>)'.'
我的项目使用这些包:
<PackageReference Include="Neo4j.Driver.Simple.Signed" Version="5.0.0" />
<PackageReference Include="Neo4jClient.DataAnnotations" Version="2.2.4" />
<PackageReference Include="Neo4jClient.Extension.Attributes.NetStandard" Version="2.0.0" />
<PackageReference Include="Neo4jClient.Extension.NetStandard" Version="2.0.0" />
你知道我在这里做错了什么吗?
我认为Where
有问题,请尝试:
var result = await CypherQuery
.Match("(tenant: Tenant)-[r]->(user: User)")
.Where((Tenant tenant) => tenant. Status == params.Status)
.AndWhere((Tenant tenant) => tenant.UserId == params.UserId)
.AndWhere((User user) => user.UserName == params.UserName)
.Return<Tenant>("tenant").ResultsAsync;
您可能可以在同一子句中使用两个Tenant
检查,但我怀疑不是这样,因为您需要AND
,而它来自AndWhere
位