Open bobmcallan opened 6 years ago
do it like this:
string collectionName = db.NameOf<Collection>();
var result= db.Query()
.Select(_ => AQL.Length(collectionName))
.First();
Thanks.
However, the result from Arango is not correct.
= 5 (?)
= 654321 (the correct number)
@bobmcallan you are right, it will return length of "Event" string, for now you should use COLLECTION_COUNT() method which is not implemented in the client right now, but you can use it by adding it as custom AQL method
public class CustomAQL
{
[UserFunction(Name = "collection_count")]
public static long CollectionCount(string collectionName)
{
throw new Exception("use custom AQL functions inside linq queries");
}
}
// usage
var result = db.Query()
.Select(_ => CustomAQL.CollectionCount(collectionName))
.First();
I ended up creating a Length Statement.
var query = string.Format("Return {{ result : LENGTH({0}) }}", collectionName);
var cntr = db.CreateStatement
Similar to your suggestion.
Please implement Collection Count/Length (AQL: "return LENGTH(Collection)).