|
1 | | -// Copyright (c) 2002-2022 "Neo4j," |
| 1 | +// Copyright (c) "Neo4j" |
2 | 2 | // Neo4j Sweden AB [http://neo4j.com] |
3 | 3 | // |
4 | 4 | // This file is part of Neo4j. |
5 | 5 | // |
6 | | -// Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +// Licensed under the Apache License, Version 2.0 (the "License"): |
7 | 7 | // you may not use this file except in compliance with the License. |
8 | 8 | // You may obtain a copy of the License at |
9 | 9 | // |
|
15 | 15 | // See the License for the specific language governing permissions and |
16 | 16 | // limitations under the License. |
17 | 17 |
|
| 18 | +using System.Collections.Generic; |
18 | 19 | using Neo4j.Driver.Experimental.FluentQueries; |
19 | 20 | using Neo4j.Driver.Internal; |
20 | 21 |
|
21 | 22 | namespace Neo4j.Driver.Experimental; |
22 | 23 |
|
23 | 24 | /// <summary> |
24 | | -/// There is no guarantee that anything in Neo4j.Driver.Experimental namespace will be in a next minor version.<br/> |
25 | | -/// This class provides access to experimental APIs on existing non-static classes. |
| 25 | +/// There is no guarantee that anything in Neo4j.Driver.Experimental namespace will be in a next minor version. |
| 26 | +/// <br /> This class provides access to experimental APIs on existing non-static classes. |
26 | 27 | /// </summary> |
27 | 28 | public static class ExperimentalExtensions |
28 | 29 | { |
29 | 30 | /// <summary> |
30 | | - /// There is no guarantee that anything in Neo4j.Driver.Experimental namespace will be in a next minor version.<br/> |
31 | | - /// Sets the <see cref="IBookmarkManager"/> for maintaining bookmarks for the lifetime of the session. |
| 31 | + /// There is no guarantee that anything in Neo4j.Driver.Experimental namespace will be in a next minor version. |
| 32 | + /// <br /> Sets the <see cref="IBookmarkManager" /> for maintaining bookmarks for the lifetime of the session. |
32 | 33 | /// </summary> |
33 | | - /// <param name="builder">This <see cref="SessionConfigBuilder"/> instance.</param> |
34 | | - /// <param name="bookmarkManager">An instance of <see cref="IBookmarkManager"/> to use in the session.</param> |
35 | | - /// <returns>this <see cref="SessionConfigBuilder"/> instance.</returns> |
36 | | - public static SessionConfigBuilder WithBookmarkManager(this SessionConfigBuilder builder, IBookmarkManager bookmarkManager) |
| 34 | + /// <param name="builder">This <see cref="SessionConfigBuilder" /> instance.</param> |
| 35 | + /// <param name="bookmarkManager">An instance of <see cref="IBookmarkManager" /> to use in the session.</param> |
| 36 | + /// <returns>this <see cref="SessionConfigBuilder" /> instance.</returns> |
| 37 | + public static SessionConfigBuilder WithBookmarkManager( |
| 38 | + this SessionConfigBuilder builder, |
| 39 | + IBookmarkManager bookmarkManager) |
37 | 40 | { |
38 | 41 | return builder.WithBookmarkManager(bookmarkManager); |
39 | 42 | } |
40 | 43 |
|
41 | 44 | /// <summary> |
42 | 45 | /// There is no guarantee that anything in Neo4j.Driver.Experimental namespace will be in a next minor version. |
43 | | - /// Gets an <see cref="IExecutableQuery"/> that can be used to configure and execute a query using |
44 | | - /// fluent method chaining. |
| 46 | + /// Gets an <see cref="IExecutableQuery<IRecord>" /> that can be used to configure and execute a query using fluent |
| 47 | + /// method chaining. |
45 | 48 | /// </summary> |
46 | 49 | /// <example> |
47 | 50 | /// The following example configures and executes a simple query, then iterates over the results. |
48 | 51 | /// <code language="cs"> |
49 | | - /// var queryResult = await driver |
50 | | - /// .ExecutableQuery("MATCH (m:Movie) WHERE m.released > $releaseYear RETURN m.title AS title") |
51 | | - /// .WithParameters(new { releaseYear = 2005 }) |
52 | | - /// .ExecuteAsync(); |
53 | | - /// |
54 | | - /// foreach(var record in queryResult) |
55 | | - /// { |
56 | | - /// Console.WriteLine(record["title"].As<string>()); |
57 | | - /// } |
58 | | - /// </code> |
| 52 | + /// var eagerResult = await driver |
| 53 | + /// .ExecutableQuery("MATCH (m:Movie) WHERE m.released > $releaseYear RETURN m.title AS title") |
| 54 | + /// .WithParameters(new { releaseYear = 2005 }) |
| 55 | + /// .ExecuteAsync(); |
| 56 | + /// <para></para> |
| 57 | + /// foreach(var record in eagerResult.Result) |
| 58 | + /// { |
| 59 | + /// Console.WriteLine(record["title"].As<string>()); |
| 60 | + /// } |
| 61 | + /// </code> |
| 62 | + /// <para></para> |
| 63 | + /// The following example gets a single scalar value from a query. |
| 64 | + /// <code> |
| 65 | + /// var born = await driver |
| 66 | + /// .ExecutableQuery("MATCH (p:Person WHERE p.name = $name) RETURN p.born AS born") |
| 67 | + /// .WithStreamProcessor(async stream => (await stream.Where(_ => true).FirstAsync())["born"].As<int>()) |
| 68 | + /// .WithParameters(new Dictionary<string, object> { ["name"] = "Tom Hanks" }) |
| 69 | + /// .ExecuteAsync(); |
| 70 | + /// <para></para> |
| 71 | + /// Console.WriteLine($"Tom Hanks born {born.Result}"); |
| 72 | + /// </code> |
59 | 73 | /// </example> |
60 | 74 | /// <param name="driver">The driver.</param> |
61 | 75 | /// <param name="cypher">The cypher of the query.</param> |
62 | | - /// <returns>An <see cref="IExecutableQuery"/> that can be used to configure and execute a query using |
63 | | - /// fluent method chaining.</returns> |
64 | | - public static IExecutableQuery ExecutableQuery(this IDriver driver, string cypher) |
| 76 | + /// <returns> |
| 77 | + /// An <see cref="IExecutableQuery<IRecord>" /> that can be used to configure and execute a query using |
| 78 | + /// fluent method chaining. |
| 79 | + /// </returns> |
| 80 | + public static IExecutableQuery<IReadOnlyList<IRecord>> ExecutableQuery(this IDriver driver, string cypher) |
65 | 81 | { |
66 | | - return new ExecutableQuery((IInternalDriver)driver, cypher); |
| 82 | + return ExecutableQuery<IReadOnlyList<IRecord>>.GetDefault((IInternalDriver)driver, cypher); |
67 | 83 | } |
68 | | - |
| 84 | + |
69 | 85 | /// <summary> |
70 | | - /// There is no guarantee that anything in Neo4j.Driver.Experimental namespace will be in a next minor version.<br/> |
71 | | - /// Experimental: This method will be removed and replaced with a readonly property "BookmarkManager" on the |
72 | | - /// <see cref="SessionConfig"/> class.<br/> |
73 | | - /// Gets the configured experimental bookmark manager from this <see cref="SessionConfig"/> instance. |
| 86 | + /// There is no guarantee that anything in Neo4j.Driver.Experimental namespace will be in a next minor version. |
| 87 | + /// <br /> Experimental: This method will be removed and replaced with a readonly property "BookmarkManager" on the |
| 88 | + /// <see cref="SessionConfig" /> class.<br /> Gets the configured experimental bookmark manager from this |
| 89 | + /// <see cref="SessionConfig" /> instance. |
74 | 90 | /// </summary> |
75 | | - /// <seealso cref="WithBookmarkManager"/> |
76 | | - /// <param name="config">This <see cref="SessionConfig"/> instance.</param> |
77 | | - /// <returns>This <see cref="SessionConfig"/>'s configured <see cref="IBookmarkManager"/> instance.</returns> |
| 91 | + /// <seealso cref="WithBookmarkManager" /> |
| 92 | + /// <param name="config">This <see cref="SessionConfig" /> instance.</param> |
| 93 | + /// <returns>This <see cref="SessionConfig" />'s configured <see cref="IBookmarkManager" /> instance.</returns> |
78 | 94 | public static IBookmarkManager GetBookmarkManager(this SessionConfig config) |
79 | 95 | { |
80 | 96 | return config.BookmarkManager; |
|
0 commit comments