I tried create collection of edges in c# via ArangoDB-NET driver (https://github.com/yojimbo87/ArangoDB-NET) and this code not working.. My code:
var response = dbClient.Collection.Type(ACollectionType.Edge).KeyGeneratorType(AKeyGeneratorType.Autoincrement).WaitForSync(true).Create(
"EdgesCollection");
dbClient is ADatabase object.
Collection is created but document type is not edge. How can I do?
I'm not familiar with that driver, and your question seems to be related to implementation, not DB functionality. However, my best guess would be to omit the KeyGeneratorType and WaitForSync options:
var cType = ACollectionType.Edge;
var cName = "EdgesCollection";
var response = dbClient.Collection.Type(cType).Create(cName);
If this fails to work, then you may need to review the docs, maybe add some other options like KeyIncrement. Generally, I would accept the defaults and only modify (or provide explicit parameters for) things that you NEED to change (i.e. "don't work").
Related
I have a bit of a weird issue. Working in C# script with SSIS I have developed a need to build a List based off Dynamic Data.
Background
To explain it, a script task is fired that has a variable API URL, this goes off and pulls a JSON string back and then throws it into a strongly typed list using the following code.
var listobject = get_APIData<ApplicationOneDataSet>(url)
The class that does this is long winded and not really needed in the context of this issue.
ApplicationOneDataSet is a strongly typed match to one of the possible JSON results returned by get_APIData.
Now I have a need to change ApplicationOneDataSet to ApplicationTwoDataSet dynamically based on which API URL I pass to the script.
So what I have done is send through a second variable to the script called class name which contains the string "ApplicationDataSetOne" or "ApplicationDataSetTwo" based on which context I call it under.
The Question
My question is how can I dynamically vary this line:
var listobject = get_APIData<ApplicationOneDataSet>(url)
With the string variable passed into the script.
My original thinking was something along the lines of this:
var ClassType = (string) Dts.Variables["AppClassName"].Value;
Type type = Type.GetType(ClassType);
var listobject = get_APIData<type>(url)
Though it doesn't seem to like that. Any tips would be great!
As long as there is exactly two types you can use and you know them at compile time, I would not look further than a simple if. It works, it's easy, everyone understands it.
You can do it totally dynamic at runtime, but that's a huge pain in the... where you don't want it to be. If you really want to go down that rabbit hole, you can find more information here.
I'm not sure I fully understood what you are trying to do, but how about writing an interface ApplicationDataSet and then making a list of it? This way your list is going to be able to contain both types of data.
I am working with Simple Odata Library
https://github.com/object/Simple.OData.Client/wiki
I need to define open parameters, but i dont seam to see any definition or documentation for this.
Example for clarification:
Along with my oData call, i send a parameter called "mode", which i can set to any number between 0-10. My server will know what to do with it. This parameter however is not pre-defined.
Recent releases of Simple.OData.Client support OData open types, look at examples here:
https://github.com/object/Simple.OData.Client/blob/master/Simple.OData.Client.IntegrationTests/TripPinTests.cs
Search for tests containing "OpenProperty".
user2824991:
I think so. I have tested the untyped and typed scenario for both query and update.
For example:
var order = await client.For("Orders")
.Set(new {OrderId = 9, OrderName = "New Order", MyProperty = "Dynamic Property", GuidProperty = Guid.NewGuid()})
.InsertEntryAsync();
Where, "OrderId" and "OrderName" are both declared properties, while "MyProperty" and "GuidProperty" are both dynamic properties.
Here's my test codes update. it belongs to my sample project.
We've created a custom Type in orchard through the Admin page, it has fields on it. How can I get access to those fields in a module?
The way I can find to do it is:
dynamic firstCourse = _contentManager.Query().ForType("Course").List().First();
var fields = firstCourse.Parts[5].Fields as List<ContentField>;
This is can't be the right solution.
dynamic firstCourse = _contentManager.Query("Course").List().First();
var myField = firstCourse.Course.MyField as WhateverTypeTheFieldIs;
This should do the trick to get the field called "MyField" but your question is unclear about what exactly you're trying to do. If you're trying to get the list of all fields, then this should work, I think:
var fields = firstCourse.Course.Fields as IEnumerable<ContentField>;
(also, you are more likely to get a good answer if you don't insult the people most likely to provide it. The documentation is open source, so go and fix it.)
Probably right in front of me, but I am not sure how to set the ReadPreference.Secondary setting in the C# driver? I wanted to distribute the query load to my secondary nodes as opposed to the default. I have set slaveOk() on the nodes themselves.
Any help / example would be appreciated. I just can't find a good example of setting that property.
Thanks,
S
EDIT: So maybe ReadPreference hasn't been implemented in C# driver yet...that looks to be the case. So then I would use slaveok?
Something like one of the below?:
var mongoServer = MongoServer.Create("mongodb://localhost/?
replicaSet=myset;slaveOk=true");
var db = mongoServer.GetDatabase("MyDb");
var coll = db.GetCollection("MyColl");
or
var cs= db.CreateCollectionSettings<BsonDocument>("Users");
cs.SlaveOk = true;
var coll = db.GetCollection(cs);
EDIT2:
Looks like I might need to modify connection string to decorate each Mongo Instance as well?
mongodb://serverA:27017,serverB:27017,serverC:27017/?safe=true;replicaset=myreplicaset;slaveok=true
Yes, ReadPreferences have not been implemented in the C# driver. We at 10gen have been waiting to implement ReadPreferences until all the drivers, including mongos, could all implement at the same time. This support should come approximately at the time of server release 2.2.
Question in the title. I am thinking of the posibility of making a DataEditor for dictionary items hosted on the current template. To make it as easy as possible to translate the page's text.
The easiest way of ascertaining the doc type of the node that your Custom Data Editor is on is to simply look it up using the Document API.
var nodeId = int.Parse(Request["id"]);
var umbracoDocument = new Document(nodeId);
Now you have the Document class you can work out the document type or interact with it in all sorts of ways. For example to get the Document Type alias:
var documentTypeAlias = d.ContentType.Alias;
There are various discussions on this approach and others here:
http://our.umbraco.org/forum/developers/extending-umbraco/7452-Document-type-alias-in-custom-datatype
http://forum.umbraco.org/yaf_postst8994_Get-Parent-Nodes-in-Custom-DataType.aspx