Example #1
0
 public QueryWriter()
 {
     queryTextBuilder = new StringBuilder();
     queryParameters  = new Dictionary <string, object>();
     resultMode       = CypherResultMode.Set;
     resultFormat     = CypherResultFormat.DependsOnEnvironment;
 }
Example #2
0
 public CypherQuery(
     string queryText,
     IDictionary <string, object> queryParameters,
     CypherResultMode resultMode,
     CypherResultFormat resultFormat,
     string database,
     IContractResolver contractResolver = null,
     int?maxExecutionTime = null,
     NameValueCollection customHeaders = null,
     bool isWrite = true,
     IEnumerable <Bookmark> bookmarks = null,
     string identifier      = null,
     bool includeQueryStats = false
     )
 {
     this.queryText        = queryText;
     this.queryParameters  = queryParameters;
     this.ResultMode       = resultMode;
     this.ResultFormat     = resultFormat;
     JsonContractResolver  = contractResolver ?? GraphClient.DefaultJsonContractResolver;
     this.MaxExecutionTime = maxExecutionTime;
     this.CustomHeaders    = customHeaders;
     IsWrite           = isWrite;
     IncludeQueryStats = includeQueryStats;
     Bookmarks         = bookmarks;
     Identifier        = identifier;
     Database          = database;
 }
Example #3
0
 public QueryWriter()
 {
     queryTextBuilder = new StringBuilder();
     queryParameters = new Dictionary<string, object>();
     resultMode = CypherResultMode.Set;
     resultFormat = CypherResultFormat.DependsOnEnvironment;
 }
Example #4
0
 QueryWriter(
     StringBuilder queryTextBuilder,
     IDictionary <string, object> queryParameters,
     CypherResultMode resultMode,
     CypherResultFormat resultFormat)
 {
     this.queryTextBuilder = queryTextBuilder;
     this.queryParameters  = queryParameters;
     this.resultMode       = resultMode;
     this.resultFormat     = resultFormat;
 }
Example #5
0
 QueryWriter(
     StringBuilder queryTextBuilder,
     IDictionary<string, object> queryParameters,
     CypherResultMode resultMode,
     CypherResultFormat resultFormat)
 {
     this.queryTextBuilder = queryTextBuilder;
     this.queryParameters = queryParameters;
     this.resultMode = resultMode;
     this.resultFormat = resultFormat;
 }
Example #6
0
 public CypherQuery(
     string queryText,
     IDictionary<string, object> queryParameters,
     CypherResultMode resultMode,
     CypherResultFormat resultFormat,
     IContractResolver contractResolver = null)
 {
     this.queryText = queryText;
     this.queryParameters = queryParameters;
     this.resultMode = resultMode;
     this.resultFormat = resultFormat;
     jsonContractResolver = contractResolver ?? GraphClient.DefaultJsonContractResolver;
 }
Example #7
0
 public CypherQuery(
     string queryText,
     IDictionary <string, object> queryParameters,
     CypherResultMode resultMode,
     CypherResultFormat resultFormat,
     IContractResolver contractResolver = null)
 {
     this.queryText       = queryText;
     this.queryParameters = queryParameters;
     this.resultMode      = resultMode;
     this.resultFormat    = resultFormat;
     jsonContractResolver = contractResolver ?? GraphClient.DefaultJsonContractResolver;
 }
Example #8
0
 public CypherJsonDeserializer(IGraphClient client, CypherResultMode resultMode, CypherResultFormat resultFormat, bool inTransaction)
 {
     this.client        = client;
     this.resultMode    = resultMode;
     this.inTransaction = inTransaction;
     // here is where we decide if we should deserialize as transactional or REST endpoint data format.
     if (resultFormat == CypherResultFormat.DependsOnEnvironment)
     {
         this.resultFormat = inTransaction ? CypherResultFormat.Transactional : CypherResultFormat.Rest;
     }
     else
     {
         this.resultFormat = resultFormat;
     }
 }
Example #9
0
 QueryWriter(
     StringBuilder queryTextBuilder,
     IDictionary <string, object> queryParameters,
     CypherResultMode resultMode,
     CypherResultFormat resultFormat,
     List <string> bookmarks,
     string identifier)
 {
     this.queryTextBuilder = queryTextBuilder;
     this.queryParameters  = queryParameters;
     this.resultMode       = resultMode;
     this.resultFormat     = resultFormat;
     this.Identifier       = identifier;
     this.bookmarks        = bookmarks;
 }
Example #10
0
 public CypherQuery(
     string queryText,
     IDictionary<string, object> queryParameters,
     CypherResultMode resultMode,
     CypherResultFormat resultFormat,
     IContractResolver contractResolver = null, 
     int? maxExecutionTime = null, 
     NameValueCollection customHeaders = null
     )
 {
     this.queryText = queryText;
     this.queryParameters = queryParameters;
     this.resultMode = resultMode;
     this.resultFormat = resultFormat;
     jsonContractResolver = contractResolver ?? GraphClient.DefaultJsonContractResolver;
     this.maxExecutionTime = maxExecutionTime;
     this.customHeaders = customHeaders;
 }
Example #11
0
 public CypherQuery(
     string queryText,
     IDictionary <string, object> queryParameters,
     CypherResultMode resultMode,
     CypherResultFormat resultFormat,
     IContractResolver contractResolver = null,
     int?maxExecutionTime = null,
     NameValueCollection customHeaders = null
     )
 {
     this.queryText        = queryText;
     this.queryParameters  = queryParameters;
     this.resultMode       = resultMode;
     this.resultFormat     = resultFormat;
     jsonContractResolver  = contractResolver ?? GraphClient.DefaultJsonContractResolver;
     this.maxExecutionTime = maxExecutionTime;
     this.customHeaders    = customHeaders;
 }
Example #12
0
 public CypherQuery(
     string queryText,
     IDictionary <string, object> queryParameters,
     CypherResultMode resultMode,
     CypherResultFormat resultFormat,
     IContractResolver contractResolver = null,
     int?maxExecutionTime = null,
     NameValueCollection customHeaders = null,
     bool isWrite = true,
     IEnumerable <string> bookmarks = null,
     string identifier = null
     )
 {
     this.queryText        = queryText;
     this.queryParameters  = queryParameters;
     this.resultMode       = resultMode;
     this.resultFormat     = resultFormat;
     jsonContractResolver  = contractResolver ?? GraphClient.DefaultJsonContractResolver;
     this.maxExecutionTime = maxExecutionTime;
     this.customHeaders    = customHeaders;
     IsWrite    = isWrite;
     Bookmarks  = bookmarks;
     Identifier = identifier;
 }
Example #13
0
 public CypherJsonDeserializer(IGraphClient client, CypherResultMode resultMode, CypherResultFormat resultFormat, bool inTransaction)
     : this(client, resultMode, resultFormat, inTransaction, false)
 {
 }
Example #14
0
 public CypherJsonDeserializer(IGraphClient client, CypherResultMode resultMode, CypherResultFormat resultFormat)
     : this(client, resultMode, resultFormat, false, false)
 {
 }
 public ExpressionBuild(string expressionText, CypherResultFormat format)
 {
     ExpressionText = expressionText;
     ResultFormat = format;
 }
Example #16
0
 public ExpressionBuild(string expressionText, CypherResultFormat format)
 {
     ExpressionText = expressionText;
     ResultFormat   = format;
 }
Example #17
0
        static ExpressionBuild BuildCypherResultItemStatement(
            MethodCallExpression expression,
            bool isNullable,
            CypherCapabilities capabilities,
            IEnumerable <JsonConverter> jsonConvertersThatTheDeserializerWillUse)
        {
            Debug.Assert(expression.Object != null, "expression.Object != null");

            string statement    = null;
            var    targetObject = expression.Object as ParameterExpression;

            if (expression.Object.Type == typeof(IFluentCypherResultItem))
            {
                var wrappedFunctionCall = BuildWrappedFunction(expression);
                statement    = wrappedFunctionCall.StatementFormat;
                targetObject = (ParameterExpression)wrappedFunctionCall.InnerExpression;
            }

            if (targetObject == null)
            {
                throw new InvalidOperationException(
                          "Somehow targetObject ended up as null. We weren't expecting this to happen. Please raise an issue at http://hg.readify.net/neo4jclient including your query code.");
            }

            var    optionalIndicator = capabilities.SupportsPropertySuffixesForControllingNullComparisons && isNullable ? "?" : "";
            string finalStatement;
            var    methodName            = expression.Method.Name;
            var    singleGenericArgument = expression.Method.IsGenericMethod
                ? expression.Method.GetGenericArguments().Single()
                : null;

            CypherResultFormat format = CypherResultFormat.DependsOnEnvironment;

            switch (methodName)
            {
            case "As":
            case "Node":
                Debug.Assert(singleGenericArgument != null);
                if (!IsSupportedForAs(singleGenericArgument, jsonConvertersThatTheDeserializerWillUse))
                {
                    throw new ArgumentException(string.Format(ReturnAsTypeShouldBeOneOfExceptionMessage, singleGenericArgument.Name), "expression");
                }
                finalStatement = string.Format("{0}{1}", targetObject.Name, optionalIndicator);
                format         = methodName == "Node" ? CypherResultFormat.Rest : CypherResultFormat.DependsOnEnvironment;
                break;

            case "CollectAs":
                if (IsNodeOrRelationshipOfT(singleGenericArgument))
                {
                    format = CypherResultFormat.Rest;
                }
                finalStatement = string.Format("collect({0})", targetObject.Name);
                break;

            case "CollectAsDistinct":
                if (IsNodeOrRelationshipOfT(singleGenericArgument))
                {
                    format = CypherResultFormat.Rest;
                }
                finalStatement = string.Format("collect(distinct {0})", targetObject.Name);
                break;

            case "Count":
                finalStatement = string.Format("count({0})", targetObject.Name);
                break;

            case "CountDistinct":
                finalStatement = string.Format("count(distinct {0})", targetObject.Name);
                break;

            case "Id":
                finalStatement = string.Format("id({0})", targetObject.Name);
                break;

            case "Length":
                finalStatement = string.Format("length({0})", targetObject.Name);
                break;

            case "Type":
                finalStatement = string.Format("type({0})", targetObject.Name);
                break;

            case "Labels":
                finalStatement = string.Format("labels({0})", targetObject.Name);
                break;

            default:
                throw new InvalidOperationException("Unexpected ICypherResultItem method definition, ICypherResultItem." + methodName);
            }

            statement = statement != null
                ? string.Format(statement, finalStatement)
                : finalStatement;

            return(new ExpressionBuild(statement, format));
        }