diff --git a/src/ArangoDB.Client/Extentions/QueryableExtensions.cs b/src/ArangoDB.Client/Extentions/QueryableExtensions.cs index 08d942d..b0cccf6 100644 --- a/src/ArangoDB.Client/Extentions/QueryableExtensions.cs +++ b/src/ArangoDB.Client/Extentions/QueryableExtensions.cs @@ -126,6 +126,11 @@ public static ICursor AsCursor(this IQueryable source) return source.AsArangoQueryable().AsCursor(); } + public static ICursor AsCursor(this IQueryable source, bool? count = null, int? batchSize = null, TimeSpan? ttl = null, QueryOption options = null) + { + return source.AsArangoQueryable().AsCursor(count, batchSize, ttl, options); + } + public static void Execute(this IAqlModifiable source) { // AsCursor is needed for executing query by ArangoQueryable methods instead of ArangoQueryExecuter diff --git a/src/ArangoDB.Client/Property/DatabaseCollectionSetting.cs b/src/ArangoDB.Client/Property/DatabaseCollectionSetting.cs index 8dcba98..405a6fa 100644 --- a/src/ArangoDB.Client/Property/DatabaseCollectionSetting.cs +++ b/src/ArangoDB.Client/Property/DatabaseCollectionSetting.cs @@ -253,9 +253,7 @@ internal string ResolvePropertyName(Type type, string memberName) public string ResolvePropertyName(Expression> attribute) { - var memberInfo = Utils.GetMemberInfo(attribute); - - return ResolvePropertyName(typeof(T), memberInfo.Name); + return ResolvePropertyName(typeof(T), Utils.GetPropertyName(attribute)); } internal string ResolveNestedPropertyName(Expression> attribute) diff --git a/src/ArangoDB.Client/Property/DocumentPropertySetting.cs b/src/ArangoDB.Client/Property/DocumentPropertySetting.cs index bb7694b..7456c31 100644 --- a/src/ArangoDB.Client/Property/DocumentPropertySetting.cs +++ b/src/ArangoDB.Client/Property/DocumentPropertySetting.cs @@ -37,7 +37,11 @@ internal static IDocumentPropertySetting FindDocumentAttributeForType(Type type, cachedAttributeProperties.TryAdd(type, typeSetting); } - return typeSetting[memberName]; + //check if the property existing in the dictionary and return it in case it does + if (typeSetting.TryGetValue(memberName, out IDocumentPropertySetting documentPropertySetting)) + return documentPropertySetting; + + return null; } internal static IDocumentPropertySetting FindDocumentAttributeForType(Expression> attribute) diff --git a/src/ArangoDB.Client/Query/ArangoQueryable.cs b/src/ArangoDB.Client/Query/ArangoQueryable.cs index aa2f39d..c385a7a 100644 --- a/src/ArangoDB.Client/Query/ArangoQueryable.cs +++ b/src/ArangoDB.Client/Query/ArangoQueryable.cs @@ -82,5 +82,11 @@ public ICursor AsCursor() return db.CreateStatement(queryData.Query , bindVars: queryData.BindVars); } + + public ICursor AsCursor(bool? count = null, int? batchSize = null, TimeSpan? ttl = null, QueryOption options = null) + { + var queryData = GetQueryData(); + return db.CreateStatement(queryData.Query, queryData.BindVars, count, batchSize, ttl, options); + } } } diff --git a/src/ArangoDB.Client/Utility/Utils.cs b/src/ArangoDB.Client/Utility/Utils.cs index a190642..99ce1d0 100644 --- a/src/ArangoDB.Client/Utility/Utils.cs +++ b/src/ArangoDB.Client/Utility/Utils.cs @@ -20,6 +20,28 @@ public static string ResolveId(string id, string collectionName = null) } } + public static string GetPropertyName(Expression> attribute) + { + const char delimiterDot = '.'; + const char delimiterPlus = '+'; + const char delimiterComma = ','; + const char endTrim = ')'; + + var asString = attribute.ToString(); // gives you: "o => o.Whatever" + //now we need to replace the plus signs with the dots in case of the nesting classes + asString = asString.Replace(delimiterPlus, delimiterDot); + // make sure there is a beginning property indicator; the "." in "o.Whatever" + var firstDotDelim = asString.IndexOf(delimiterDot); + var firstCommaDelim = asString.IndexOf(delimiterComma); + + if (firstDotDelim < 0) + return asString; + else if (firstCommaDelim < 0) + return asString.Substring(firstDotDelim + 1).TrimEnd(endTrim); + else + return asString.Substring(firstDotDelim + 1, firstCommaDelim - firstDotDelim - 1); + } + public static MemberInfo GetMemberInfo(Expression> attribute) { return GetMemberExpression(attribute).Member;