LoginRequest()
, which will allow the users to login to a
specific namespace.
In order to create a Dgraph client, and make the client login into namespace
123
:
123
using username
userId
and password password
. Once logged in, the client can perform all the
operations allowed to the userId
user of namespace 123
.
DgraphClient.Alter
function, as
seen below:
result.isSuccess
or result.isFailed
. More information on
the result object can be found here.
DgraphClient.NewTransaction
method, which
returns a new Transaction
object. This operation incurs no network overhead.
It is good practice to call to wrap the Transaction
in a using
block, so
that the Transaction.Dispose
function is called after running the transaction.
DgraphClient.NewReadOnlyTransaction
.
Transaction.Mutate(RequestBuilder)
runs a mutation. It takes in a json
mutation string.
We define a person object to represent a person and serialize it to a json
mutation string. In this example, we are using the
JSON.NET library, but you can use any JSON
serialization library you prefer.
source/Dgraph.tests.e2e/TransactionTest.cs
.
Transaction.Query(string)
. You will need to
pass in a DQL query string. If you want to pass an additional map of any
variables that you might want to set in the query, call
Transaction.QueryWithVars(string, Dictionary<string,string>)
with the
variables dictionary as the second argument.
The response would contain the response string.
Letβs run the following query with a variable $a
:
Transaction.Mutate
function allows you to run upserts consisting of one
query and one mutation.
Transaction.Commit
method. If your
transaction consisted solely of calls to Transaction.Query
or
Transaction.QueryWithVars
, and no calls to Transaction.Mutate
, then calling
Transaction.Commit
is not necessary.
An error will be returned if other transactions running concurrently modify the
same data that was modified in this transaction. It is up to the user to retry
transactions when they fail.