Comments (8)
Example queries below:
FOR id IN GRAPH_NEIGHBORS('Test', 'doc/id', {direction:'outbound', maxDepth:1, edgeExamples:[{attr:'value'}]})
FOR u IN User
FILTER u._id == id
RETURN u
Instead below:
FOR id IN GRAPH_NEIGHBORS('Test', 'doc/id', {direction:'outbound', maxDepth:1, edgeExamples:[{attr:'value'}]})
RETURN document(id)
from arangoclient.net.
@drgraduss aql has Document
function you can look it at Miscellaneous functions, unfortunately i didn't add Miscellaneous functions
yet, but you can add them with the following code:
this is how you can add custom AQL functions too:
public class CustomAQL
{
[UserFunction(Name = "document")]
public static T Document<T>(string id)
{
throw new Exception("use custom AQL functions inside linq queries");
}
[UserFunction(Name = "document")]
public static IList<T> Document<T>(IList<string> ids)
{
throw new Exception("use custom AQL functions inside linq queries");
}
}
// and use them like:
var query1 = db.Query().Select(_ => CustomAQL.Document<Person>("Person/123"));
// output: return document("Person/123")
Console.WriteLine(query1.GetQueryData().QueryReplacedWithVariables(db));
var query2 = db.Query().Select(_ => CustomAQL.Document<Person>(new string[] { "Person/123" }));
// output: return document( ["Person/123"] )
Console.WriteLine(query2.GetQueryData().QueryReplacedWithVariables(db));
i will add Miscellaneous functions
in next release
from arangoclient.net.
A bit of context. Consider query below:
db.Query().For(x =>
AQL.GraphNeighbors<Vertex>(
"graph-name",
new { _key = "vertex-key" },
new
{
direction = EdgeDirection.Outbound,
maxDepth = 1,
edgeExamples = new[] { new { attr = "edge-attr-filter" } }
}));
This query will throw ArangoDB.Client.Common.Newtonsoft.Json.JsonSerializationException: cannot convert value 'string' to type 'Vertex'
. Using AQL.GraphNeighbors<Vertex>()
and AQL.GraphNeighbors<string>
will produce the same query:
for
generated_0in graph_neighbors( @P1 , @P2 , @P3 ) return
generated_0``
which works in the second example.
If you change query to
for
generated_0 in graph_neighbors( @P1 , @P2 , @P3 ) return document(
generated_0)
(by adding document
function) query works in first example as well.
That was my original issue. Sorry for being a bit long.
from arangoclient.net.
@drgraduss i'm not deep into graphs but if you look at the method signature:
public static IList<TVertexResult> GraphNeighbors<TVertexResult>(string graphName, object vertexExample, object options)
the reason that i named the generic parameter TVertexResult
is for includeData
option parameter which if set to true
result will be full documents instead of their ids. this may solve your problem
otherwise you can still write it like below, but includeData
would give you more performance(at least i think)
var query = db.Query().For(_ =>
AQL.GraphNeighbors<string>(
"graph-name",
new { _key = "vertex-key" },
new
{
direction = EdgeDirection.Outbound,
maxDepth = 1,
edgeExamples = new[] { new { attr = "edge-attr-filter" } }
})
.Select(id=> CustomAQL.Document<Vertex>(id)));
from arangoclient.net.
Thanks a lot, @ra0o0f. I completely missed includeData
option. CustomAQL works as well,
but I will stick with includeData
. It's just not obvious when it's legal to use document type as TVertexResult
and not a string
.
Thanks for your help!
from arangoclient.net.
@drgraduss you are right, there should be document for all of this but i can't provide it until next month. but the API is so much similar to the internal javascript API at the ArangoDB website, i hope it can help until i provide one
from arangoclient.net.
@ra0o0f Not a problem at all. Trial and error works best as usual :)
from arangoclient.net.
The attached patch allows db.Document(id) to be used in LINQ statements. For example:
from user in db.Query<User>()
let dept = db.Document<Department>(user.dept_id)
where dept.name == "cars"
select user
This would previously throw an exception like "Method Document not being supported in ArangoLinqProvider."
from arangoclient.net.
Related Issues (20)
- ArangoServerException not throw when db unavailable HOT 2
- Thread safety HOT 7
- Confused with SystemDatabaseCredential HOT 5
- Custom Index HOT 6
- ByExampleAsync missing HOT 2
- Make ChangeCollectionPropertyForType public HOT 1
- Using LINQ query with Where performance HOT 1
- Error in generated AQL when upserting a generic document HOT 7
- ArangoServerException eats up all the useful information like status code and error number HOT 2
- Make collection name resolver more extensible HOT 2
- Annotating a property of type Guid as DocumentProperty.Key throws InvalidCastException HOT 2
- Support private setter
- CreateStatement<object> & Remove Vertex HOT 1
- Ternary operator support
- Global error handling policy
- Support for keyOptions: uuid
- Edge Document API not supported?
- Cannot Simply Connect to Server...... HOT 2
- Secure connection to ArangoDB
- Query directly within a collection
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arangoclient.net.