本文整理汇总了C#中Arango.Client.ADatabase类的典型用法代码示例。如果您正苦于以下问题:C# ADatabase类的具体用法?C# ADatabase怎么用?C# ADatabase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ADatabase类属于Arango.Client命名空间,在下文中一共展示了ADatabase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Issue_No16_SortedList
public void Issue_No16_SortedList()
{
Database.CreateTestCollection(Database.TestDocumentCollectionName, ACollectionType.Document);
var db = new ADatabase(Database.Alias);
var entity = new IssueNo16Entity();
entity.SortedList = new SortedList<int, bool>();
entity.SortedList.Add(1, true);
entity.SortedList.Add(2, false);
entity.SortedList.Add(3, false);
entity.SortedList.Add(4, false);
var createResult = db.Document.Create(Database.TestDocumentCollectionName, entity);
Assert.IsTrue(createResult.Success);
var getResult = db.Document.Get<IssueNo16Entity>(createResult.Value.ID());
Assert.IsTrue(getResult.Success);
Assert.IsTrue(getResult.HasValue);
for (int i = 0; i < getResult.Value.SortedList.Count; i++)
{
Assert.AreEqual(entity.SortedList.ElementAt(i).Key, getResult.Value.SortedList.ElementAt(i).Key);
Assert.AreEqual(entity.SortedList.ElementAt(i).Value, getResult.Value.SortedList.ElementAt(i).Value);
}
}
示例2: Should_execute_AQL_query_with_batchSize
public void Should_execute_AQL_query_with_batchSize()
{
var documents = Database.ClearCollectionAndFetchTestDocumentData(Database.TestDocumentCollectionName);
var db = new ADatabase(Database.Alias);
var doc3 = new Dictionary<string, object>()
.String("foo", "foo string 3");
db.Document
.Create(Database.TestDocumentCollectionName, doc3);
var doc4 = new Dictionary<string, object>()
.String("foo", "foo string 4");
db.Document
.Create(Database.TestDocumentCollectionName, doc4);
var queryResult = db.Query
.BatchSize(1)
.Aql(string.Format(@"
FOR item IN {0}
RETURN item
", Database.TestDocumentCollectionName))
.ToList();
Assert.AreEqual(200, queryResult.StatusCode);
Assert.IsTrue(queryResult.Success);
Assert.IsTrue(queryResult.HasValue);
Assert.AreEqual(queryResult.Value.Count, 4);
}
示例3: Issue_No15_List_save_and_retrieve
public void Issue_No15_List_save_and_retrieve()
{
Database.CreateTestCollection(Database.TestDocumentCollectionName, ACollectionType.Document);
var db = new ADatabase(Database.Alias);
var entity = new IssueNo15Entity();
entity.ListNumbers = new List<int> { 1, 2, 3 };
entity.ArrayNumbers = new int[] { 4, 5, 6};
var createResult = db.Document.Create(Database.TestDocumentCollectionName, entity);
Assert.IsTrue(createResult.Success);
var getresult = db.Document.Get<IssueNo15Entity>(createResult.Value.ID());
Assert.IsTrue(getresult.Success);
Assert.IsTrue(getresult.HasValue);
for (int i = 0; i < getresult.Value.ListNumbers.Count; i++)
{
Assert.AreEqual(entity.ListNumbers[i], getresult.Value.ListNumbers[i]);
}
for (int i = 0; i < getresult.Value.ArrayNumbers.Length; i++)
{
Assert.AreEqual(entity.ArrayNumbers[i], getresult.Value.ArrayNumbers[i]);
}
}
示例4: Should_replace_function
public void Should_replace_function()
{
Database.CreateTestDatabase(Database.TestDatabaseGeneral);
var db = new ADatabase(Database.Alias);
var registerResult = db.Function.Register(
"myfunctions::temperature::celsiustofahrenheit",
"function (celsius) { return celsius * 1.8 + 40; }"
);
Assert.AreEqual(201, registerResult.StatusCode);
Assert.IsTrue(registerResult.Success);
Assert.IsTrue(registerResult.HasValue);
Assert.IsTrue(registerResult.Value);
var replaceResult = db.Function.Register(
"myfunctions::temperature::celsiustofahrenheit",
"function (celsius) { return celsius * 1.8 + 32; }"
);
Assert.AreEqual(200, replaceResult.StatusCode);
Assert.IsTrue(replaceResult.Success);
Assert.IsTrue(replaceResult.HasValue);
Assert.IsTrue(replaceResult.Value);
const int celsius = 30;
const float fahrenheit = celsius * 1.8f + 32;
var queryResult = db.Query
.BindVar("celsius", celsius)
.Aql("return myfunctions::temperature::celsiustofahrenheit(@celsius)")
.ToList<float>();
Assert.AreEqual(fahrenheit, queryResult.Value.First());
}
示例5: Should_change_collection_properties
public void Should_change_collection_properties()
{
Database.CreateTestDatabase(Database.TestDatabaseGeneral);
var db = new ADatabase(Database.Alias);
var createResult = db.Collection
.Create(Database.TestDocumentCollectionName);
const long journalSize = 199999999;
var operationResult = db.Collection
.WaitForSync(true)
.JournalSize(journalSize)
.ChangeProperties(createResult.Value.String("name"));
Assert.AreEqual(200, operationResult.StatusCode);
Assert.IsTrue(operationResult.Success);
Assert.IsTrue(operationResult.HasValue);
Assert.AreEqual(createResult.Value.String("id"), operationResult.Value.String("id"));
Assert.AreEqual(createResult.Value.String("name"), operationResult.Value.String("name"));
Assert.AreEqual(createResult.Value.Bool("isSystem"), operationResult.Value.Bool("isSystem"));
Assert.AreEqual(createResult.Value.Int("status"), operationResult.Value.Int("status"));
Assert.AreEqual(createResult.Value.Int("type"), operationResult.Value.Int("type"));
Assert.IsFalse(operationResult.Value.Bool("isVolatile"));
Assert.IsTrue(operationResult.Value.Bool("doCompact"));
Assert.AreEqual(AKeyGeneratorType.Traditional, operationResult.Value.Enum<AKeyGeneratorType>("keyOptions.type"));
Assert.IsTrue(operationResult.Value.Bool("keyOptions.allowUserKeys"));
Assert.IsTrue(operationResult.Value.Bool("waitForSync"));
Assert.IsTrue(operationResult.Value.Long("journalSize") == journalSize);
}
示例6: Should_list_functions
public void Should_list_functions()
{
Database.CreateTestDatabase(Database.TestDatabaseGeneral);
var db = new ADatabase(Database.Alias);
const string name1 = "myfunctions::temperature::celsiustofahrenheit1";
const string code1 = "function (celsius) { return celsius * 1.8 + 40; }";
var registerResult1 = db.Function.Register(name1, code1);
Assert.AreEqual(true, registerResult1.Success);
const string name2 = "myfunctions::temperature::celsiustofahrenheit2";
const string code2 = "function (celsius) { return celsius * 1.8 + 32; }";
var registerResult2 = db.Function.Register(name2, code2);
Assert.AreEqual(true, registerResult2.Success);
var listResult = db.Function.List();
Assert.AreEqual(200, listResult.StatusCode);
Assert.IsTrue(listResult.Success);
Assert.IsTrue(listResult.HasValue);
Assert.AreEqual(2, listResult.Value.Count);
// retrieved order of the functions seems to be reversed
Assert.AreEqual(name2, listResult.Value[0].String("name"));
Assert.AreEqual(code2, listResult.Value[0].String("code"));
Assert.AreEqual(name1, listResult.Value[1].String("name"));
Assert.AreEqual(code1, listResult.Value[1].String("code"));
}
示例7: Should_execute_AQL_query_fluent
public void Should_execute_AQL_query_fluent()
{
var documents = Database.ClearCollectionAndFetchTestDocumentData(Database.TestDocumentCollectionName);
var db = new ADatabase(Database.Alias);
var useCount = true;
var useBatchSize = true;
var queryOperation = db.Query
.Aql(string.Format(@"
FOR item IN {0}
RETURN item
", Database.TestDocumentCollectionName));
if (useCount)
{
queryOperation.Count(true);
}
if (useBatchSize)
{
queryOperation.BatchSize(1);
}
var queryResult = queryOperation.ToList();
Assert.AreEqual(200, queryResult.StatusCode);
Assert.IsTrue(queryResult.Success);
Assert.IsTrue(queryResult.HasValue);
Assert.AreEqual(queryResult.Value.Count, 2);
Assert.AreEqual(queryResult.Extra.Long("count"), 2);
}
示例8: Should_execute_get_foxx_request
public void Should_execute_get_foxx_request()
{
var db = new ADatabase(Database.SystemAlias);
var getResult = db.Foxx.Get<Dictionary<string, object>>("/getting-started/hello-world");
Assert.AreEqual(200, getResult.StatusCode);
Assert.AreEqual("bar", getResult.Value.String("foo"));
}
示例9: Should_check_document
public void Should_check_document()
{
var documents = Database.ClearCollectionAndFetchTestDocumentData(Database.TestDocumentCollectionName);
var db = new ADatabase(Database.Alias);
var checkResult = db.Document
.Check(documents[0].String("_id"));
Assert.AreEqual(200, checkResult.StatusCode);
Assert.IsTrue(checkResult.Success);
Assert.IsTrue(checkResult.HasValue);
Assert.AreEqual(checkResult.Value, documents[0].String("_rev"));
}
示例10: Should_create_database
public void Should_create_database()
{
Database.CleanupTestDatabases();
var db = new ADatabase(Database.SystemAlias);
var createResult = db.Create(Database.TestDatabaseOneTime);
Assert.AreEqual(201, createResult.StatusCode);
Assert.IsTrue(createResult.Success);
Assert.IsTrue(createResult.HasValue);
Assert.IsTrue(createResult.Value);
}
示例11: Should_check_document_with_ifMatch_and_return_412
public void Should_check_document_with_ifMatch_and_return_412()
{
var documents = Database.ClearCollectionAndFetchTestDocumentData(Database.TestDocumentCollectionName);
var db = new ADatabase(Database.Alias);
var checkResult = db.Document
.IfMatch("123456789")
.Check(documents[0].String("_id"));
Assert.AreEqual(412, checkResult.StatusCode);
Assert.IsFalse(checkResult.Success);
Assert.IsTrue(checkResult.HasValue);
Assert.AreEqual(checkResult.Value, documents[0].String("_rev"));
}
示例12: Should_execute_post_foxx_request_with_body
public void Should_execute_post_foxx_request_with_body()
{
var db = new ADatabase(Database.SystemAlias);
var body = Dictator.New()
.String("foo", "some string");
var postResult = db.Foxx
.Body(body)
.Post<Dictionary<string, object>>("/getting-started/hello-world");
Assert.AreEqual(200, postResult.StatusCode);
Assert.AreEqual(body.String("foo"), postResult.Value.String("foo"));
}
示例13: Should_check_document_with_ifNoneMatch
public void Should_check_document_with_ifNoneMatch()
{
var documents = Database.ClearCollectionAndFetchTestDocumentData(Database.TestDocumentCollectionName);
var db = new ADatabase(Database.Alias);
var checkResult = db.Document
.IfNoneMatch("123456789")
.Check(documents[0].ID());
Assert.AreEqual(200, checkResult.StatusCode);
Assert.IsTrue(checkResult.Success);
Assert.IsTrue(checkResult.HasValue);
Assert.AreEqual(checkResult.Value, documents[0].Rev());
}
示例14: Should_delete_database
public void Should_delete_database()
{
Database.CleanupTestDatabases();
var db = new ADatabase(Database.SystemAlias);
var createResult = db.Create(Database.TestDatabaseGeneral);
var deleteResult = db.Drop(Database.TestDatabaseGeneral);
Assert.AreEqual(200, deleteResult.StatusCode);
Assert.IsTrue(deleteResult.Success);
Assert.IsTrue(deleteResult.HasValue);
Assert.IsTrue(deleteResult.Value);
}
示例15: Should_fail_create_already_existing_database
public void Should_fail_create_already_existing_database()
{
Database.CleanupTestDatabases();
var db = new ADatabase(Database.SystemAlias);
var createResult = db.Create(Database.TestDatabaseGeneral);
var createResult2 = db.Create(Database.TestDatabaseGeneral);
Assert.AreEqual(409, createResult2.StatusCode);
Assert.IsFalse(createResult2.Success);
Assert.IsTrue(createResult2.HasValue);
Assert.IsFalse(createResult2.Value);
Assert.IsNotNull(createResult2.Error);
}