orientechnologies / orientdb-net.binary Goto Github PK
View Code? Open in Web Editor NEWC#/.NET binary driver for OrientDB
License: MIT License
C#/.NET binary driver for OrientDB
License: MIT License
Are there possibly any older versions of the OrientDB-NET.binary available that might be compatible with .NET 3.5? Thanks.
I have been using this driver for version 1.7.9, but when I update to OrientDB 2.0rc, the driver can no longer be functional.
The driver just hangs when calling Response.Receive() method, More specifically on
Status = (ResponseStatus)reader.ReadByte();
I am using the latest version of this driver on the Master branch.
Hi,
I get an ArgumentException on OClient.CreateDatabasePool, with message "Requested value 'none' was not found".
My code :
OClient.CreateDatabasePool(
"localhost",
2424,
"GratefulDeadConcerts",
ODatabaseType.Graph,
"root",
"root",
10,
"AppConnection"
);
Stacktrace :
à System.Enum.EnumResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument)
à System.Enum.TryParseEnum(Type enumType, String value, Boolean ignoreCase, EnumResult& parseResult)
à System.Enum.Parse(Type enumType, String value, Boolean ignoreCase)
à Orient.Client.Protocol.Operations.DbOpen.Response(Response response)
à Orient.Client.Protocol.Connection.ExecuteOperation[T](T operation)
à Orient.Client.Protocol.Connection.InitializeDatabaseConnection(String databaseName, ODatabaseType databaseType, String userName, String userPassword)
à Orient.Client.Protocol.Connection..ctor(String hostname, Int32 port, String databaseName, ODatabaseType databaseType, String userName, String userPassword, String alias, Boolean isReusable)
à Orient.Client.Protocol.DatabasePool..ctor(String hostname, Int32 port, String databaseName, ODatabaseType databaseType, String userName, String userPassword, Int32 poolSize, String alias)
à Orient.Client.OClient.CreateDatabasePool(String hostname, Int32 port, String databaseName, ODatabaseType databaseType, String userName, String userPassword, Int32 poolSize, String alias)
The EndOfStream
method was introduced in commit 72b9244 but the GetField
method returns null when running on Mono.
If I change EndOfStream to always return false, then all the tests pass on Mono when connecting to OrientDB 2.0.
I've tried to duplicate the logic with Mono but so far haven't been able to. Before I dig into it more please help me understand why EndOfStream is needed. The simplest fix I know of right now is to detect if Mono is the runtime and just return false. Please advise.
Hi,
My colleague encountered a problem whenever he tried to retrieve save the object with 2 different properties with same class type. He figure out the data was not stored correct. The bug has been fixed by him at cychua2015@6bfe04e. Please merge and we shall test again thereafter. Thanks.
Cordially,
Goh
Hi,
I am encountering issues on some data types like List and array with enum type.
Here's the code.
public static void TestOrientDBObjectTypeSupported()
{
var GlobalTestDatabaseName = "TestDatabaseNameAlias";
var GlobalTestDatabaseType = ODatabaseType.Graph;
var GlobalTestDatabaseAlias = "TestDatabaseNameAlias";
_server = new OServer(_hostname, _port, _rootUserName, _rootUserParssword);
if (_server.DatabaseExist(GlobalTestDatabaseName, OStorageType.PLocal))
{
_server.DropDatabase(GlobalTestDatabaseName, OStorageType.PLocal);
}
_server.CreateDatabase(GlobalTestDatabaseName, GlobalTestDatabaseType, OStorageType.PLocal);
OClient.CreateDatabasePool(
_hostname,
_port,
GlobalTestDatabaseName,
GlobalTestDatabaseType,
_username,
_password,
10,
GlobalTestDatabaseAlias
);
DateTime startTime = DateTime.Now;
Console.WriteLine("Start Time: " + startTime.ToLongTimeString());
using (ODatabase database = new ODatabase(GlobalTestDatabaseName))
{
database.Create.Class<DemoEmployee>().Run();
for (int index = 1; index <= 1; index++)
{
var employee = new DemoEmployee();
employee.SomeOtherId = Guid.NewGuid();
employee.Name = "Janet";
employee.Age = index;
employee.WorkingDays = new List<DayOfWeek>();
employee.WorkingDays.Add(DayOfWeek.Monday);
employee.WorkingDays.Add(DayOfWeek.Tuesday);
employee.WorkingDays.Add(DayOfWeek.Wednesday);
database.Insert<DemoEmployee>(employee).Run();
}
}
}
public class DemoEmployee
{
public Guid SomeOtherId { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public long SomeVeryLongNumber { get; set; }
public decimal Salary { get; set; }
public List<DayOfWeek> WorkingDays { get; set; }
public DateTime? IncrementDate { get; set; }
public int? Height { get; set; }
public double Commission { get; set; }
public float Allowance { get; set; }
public DateTime BirthDate { get; set; }
public bool IsMarried { get; set; }
public List<int> SomeIntegerList { get; set; }
public int[] SomeIntegerArrayList { get; set; }
public List<decimal> SomeDecimalList { get; set; }
public decimal[] SomeDecomeArray { get; set; }
public List<DemoChild> Kids { get; set; }
public IList<int> SomeIListInteger { get; set; }
public Dictionary<int, string> MyKeyValues { get; set; }
public SortedList<int, string> YearlyAchievement { get; set; }
public Color MyFavoriteColor { get; set; }
public enum Color
{
Blue, Red
}
}
Please let me know if you need more info. Thanks.
Cordially,
Goh
Lately I have to change the name for one of my class so I executed the following command.
ALTER CLASS Users NAME user
Then when I try to access it using the following code it throws an exception.
using (var database = Settings.GetDatabase())
{
database
.Create
.Vertex("user")
.Run();
}
This is a screen shot of the code that threw the exception.
As you can see the class name and the cluster name is not the same, but the driver is try to match the cluster id with the class name.
This is the link for the exported version of my test database/
https://onedrive.live.com/redir?resid=A926F63081BDBEAF%213230
I'm not sure this issue has been already reported or not. Issue is
My web application is already running. Connection pool is initialized only once in a static constructor. It works fine and I can connect to database and make queries.
If I restart orient-db server, then all queries break with IOException "Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host."
If I try to drop connection pool in case of IO error again i get same error. So, I have to restart web server to make it work again.
As per my investigation I get error in Connection.ExecuteOperation method at code : _networkStream.Flush();
Thanks
Say for example that I have a node Person that has out edges of type Friend that leads to another person as an in edge.
If I want to make a friend edge between two persons with the current driver inside a transaction I have to first load Person1 and Person2 (or create Person2 if its a new person) and then add the ORID of each other into the respective collections (talking about light edges, but heavy edges are not that different). This looks fine in the test cases but in a real world scenario I would have to load a person that might have 1000s of items in the list of outgoing or incoming edges and add to that collection which leads to performance issues and concurrency exceptions.
It would be great if you could create edges inside a transaction in a similar manner to "Create edge from #1 to #2" without loading the nodes first.
I am not 100% sure but I think the java and nodejs client are already doing this way.
[Test]
public void GIVEN___EmployeeArrayType_class_with_common_data_type___WHEN___write_to_orientdb___THEN___should_be_able_to_read()
{
var employeeClassName = "EmployeeArrayType";
var employee = new EmployeeArrayType();
employee.Id = Guid.NewGuid();
employee.Name = new string[2];
employee.Name[0] = "Andrew";
employee.Name[1] = ("Jack");
employee.Age = new int[2];
employee.Age[0] = (1);
employee.Age[1] = (2);
employee.BirthDate = new DateTime[2];
employee.BirthDate[0] = (DateTime.Now);
employee.BirthDate[1] = (DateTime.Now.AddDays(-3));
employee.Childs = new EmployeeCommonType[2];
employee.Childs[0] = (new EmployeeCommonType() { Id = Guid.NewGuid() });
employee.Childs[1] = (new EmployeeCommonType() { Id = Guid.NewGuid() });
employee.FavoriteColor = new Color[2];
employee.FavoriteColor[0] = (Color.Red);
employee.FavoriteColor[1] = (Color.Blue);
employee.Height = new short[2];
employee.Height[0] = (323);
employee.Height[1] = (333);
employee.Ids = new Guid[2];
employee.Ids[0] = (Guid.NewGuid());
employee.Ids[1] = (Guid.NewGuid());
employee.IsMarried = new bool[2];
employee.IsMarried[0] = (true);
employee.IsMarried[1] = (false);
employee.Salary = new decimal[2];
employee.Salary[0] = ((decimal)1234567890.123456789);
employee.Salary[1] = ((decimal)1234567890.123456799);
employee.Tall = new long[2];
employee.Tall[0] = (3233);
employee.Tall[1] = (3234);
employee.YearlyIncome = new double[2];
employee.YearlyIncome[0] = (3233);
employee.YearlyIncome[1] = (1234);
// my own OrientDb wrapper
writer.Insert<EmployeeArrayType>(employee, DatabaseName, employeeClassName);
using (var database = new ODatabase(DatabaseName))
{
var result = database.Query<EmployeeListType>("SELECT * FROM " + employeeClassName + " WHERE Id = '" + employee.Id + "'").SingleOrDefault();
Assert.AreEqual(employee.Id, result.Id);
Assert.AreEqual(employee.Ids[0], result.Ids[0]);
Assert.AreEqual(employee.Ids[1], result.Ids[1]);
Assert.AreEqual(employee.Name[0], result.Name[0]);
Assert.AreEqual(employee.Name[1], result.Name[1]);
Assert.AreEqual(employee.Age[0], result.Age[0]);
Assert.AreEqual(employee.Age[1], result.Age[1]);
Assert.AreEqual(employee.Age[0], result.Age[0]);
Assert.AreEqual(employee.Salary[0], result.Salary[0]);
Assert.AreEqual(employee.Salary[1], result.Salary[1]);
Assert.AreEqual(employee.IsMarried[0], result.IsMarried[0]);
Assert.AreEqual(employee.IsMarried[1], result.IsMarried[1]);
Assert.AreEqual(employee.Childs[0].Id, result.Childs[0].Id);
Assert.AreEqual(employee.Childs[1].Id, result.Childs[1].Id);
Assert.AreEqual(employee.BirthDate[0].ToLongDateString(), result.BirthDate[0].ToLongDateString());
Assert.AreEqual(employee.BirthDate[1].ToLongDateString(), result.BirthDate[1].ToLongDateString());
Assert.AreEqual(employee.YearlyIncome[0], result.YearlyIncome[0]);
Assert.AreEqual(employee.YearlyIncome[1], result.YearlyIncome[1]);
Assert.AreEqual(employee.FavoriteColor[0], result.FavoriteColor[0]);
Assert.AreEqual(employee.FavoriteColor[1], result.FavoriteColor[1]);
Assert.AreEqual(employee.Height[0], result.Height[0]);
Assert.AreEqual(employee.Height[1], result.Height[1]);
Assert.AreEqual(employee.Tall[0], result.Tall[0]);
Assert.AreEqual(employee.Tall[1], result.Tall[1]);
database.Command("DELETE FROM " + employeeClassName + " WHERE Id = '" + employee.Id + "'");
}
}
public class EmployeeArrayType
{
public Guid Id { get; set; }
public Guid[] Ids { get; set; }
public string[] Name { get; set; }
public int[] Age { get; set; }
public decimal[] Salary { get; set; }
public bool[] IsMarried { get; set; }
public DateTime[] BirthDate { get; set; }
public double[] YearlyIncome { get; set; }
public short[] Height { get; set; }
public long[] Tall { get; set; }
public Color[] FavoriteColor { get; set; }
public EmployeeCommonType[] Childs { get; set; }
}
The all upper case class name "ORID" should be modified to "Orid" to conform with standard .NET naming conventions and guidelines.
The client cache is not being populated when fetching documents connected by edges. I'll submit a test case.
ODatabase.Query()
currently returns a List<ODocument>
. When executing a SQL query that cannot be handled with the fluent API, it would be helpful to easily convert the Query results to a List
of another type.
Hi,
I have encountered another problem on SortedList type for database.Insert. Here's the code
[Test]
public void GIVEN___EmployeeSortedListType_class_with_common_data_type___WHEN___write_to_orientdb___THEN___should_be_able_to_read()
{
var employeeClassName = "EmployeeDictionaryType";
var employee = new EmployeeSortedListType();
employee.Id = Guid.NewGuid();
employee.Name = new SortedList<string, string>();
employee.Name.Add("Andrew", "Andrew");
employee.Name.Add("Jack", "Jack");
employee.Age = new SortedList<int, int>();
employee.Age.Add(1, 2);
employee.Age.Add(2, 4);
employee.BirthDate = new SortedList<DateTime, DateTime>();
employee.BirthDate.Add(DateTime.Now, DateTime.Now.AddDays(1));
employee.BirthDate.Add(DateTime.Now.AddDays(-3), DateTime.Now.AddDays(-2));
employee.Childs = new SortedList<int, EmployeeCommonType>();
employee.Childs.Add(1, new EmployeeCommonType() { Id = Guid.NewGuid() });
employee.Childs.Add(2, new EmployeeCommonType() { Id = Guid.NewGuid() });
employee.FavoriteColor = new SortedList<Color, Color>();
employee.FavoriteColor.Add(Color.Red, Color.Red);
employee.FavoriteColor.Add(Color.Blue, Color.Blue);
employee.Height = new SortedList<short, short>();
employee.Height.Add(1, 323);
employee.Height.Add(2, 333);
employee.Ids = new SortedList<Guid, Guid>();
employee.Ids.Add(Guid.NewGuid(), Guid.NewGuid());
employee.Ids.Add(Guid.NewGuid(), Guid.NewGuid());
employee.IsMarried = new SortedList<bool, bool>();
employee.IsMarried.Add(true, true);
employee.IsMarried.Add(false, false);
employee.Salary = new SortedList<decimal, decimal>();
employee.Salary.Add((decimal)1, (decimal)1234567890.123456789);
employee.Salary.Add((decimal)2, (decimal)1234567890.123456799);
employee.Tall = new SortedList<long, long>();
employee.Tall.Add(1, 3233);
employee.Tall.Add(2, 3234);
employee.YearlyIncome = new SortedList<double, double>();
employee.YearlyIncome.Add(2, 3233);
employee.YearlyIncome.Add(4, 1234);
using (var database = new ODatabase(DatabaseName))
{
database.Insert(employee)
.Into(employeeClassName)
.Run();
var result = database.Query<EmployeeSortedListType>("SELECT * FROM " + employeeClassName + " WHERE Id = '" + employee.Id + "'").SingleOrDefault();
Assert.AreEqual(employee.Id, result.Id);
Assert.AreEqual(employee.Ids.ToList()[0].Key, result.Ids.ToList()[0].Key);
Assert.AreEqual(employee.Ids.ToList()[1].Key, result.Ids.ToList()[1].Key);
Assert.AreEqual(employee.Ids.ToList()[0].Value, result.Ids.ToList()[0].Value);
Assert.AreEqual(employee.Ids.ToList()[1].Value, result.Ids.ToList()[1].Value);
Assert.AreEqual(employee.Name.ToList()[0].Key, result.Name.ToList()[0].Key);
Assert.AreEqual(employee.Name.ToList()[1].Key, result.Name.ToList()[1].Key);
Assert.AreEqual(employee.Name.ToList()[0].Value, result.Name.ToList()[0].Value);
Assert.AreEqual(employee.Name.ToList()[1].Value, result.Name.ToList()[1].Value);
Assert.AreEqual(employee.Age.ToList()[0].Key, result.Age.ToList()[0].Key);
Assert.AreEqual(employee.Age.ToList()[1].Key, result.Age.ToList()[1].Key);
Assert.AreEqual(employee.Age.ToList()[0].Value, result.Age.ToList()[0].Value);
Assert.AreEqual(employee.Age.ToList()[1].Value, result.Age.ToList()[1].Value);
Assert.AreEqual(employee.Salary.ToList()[0].Key, result.Salary.ToList()[0].Key);
Assert.AreEqual(employee.Salary.ToList()[1].Key, result.Salary.ToList()[1].Key);
Assert.AreEqual(employee.Salary.ToList()[0].Value, result.Salary.ToList()[0].Value);
Assert.AreEqual(employee.Salary.ToList()[1].Value, result.Salary.ToList()[1].Value);
Assert.AreEqual(employee.IsMarried.ToList()[0].Key, result.IsMarried.ToList()[0].Key);
Assert.AreEqual(employee.IsMarried.ToList()[1].Key, result.IsMarried.ToList()[1].Key);
Assert.AreEqual(employee.IsMarried.ToList()[0].Value, result.IsMarried.ToList()[0].Value);
Assert.AreEqual(employee.IsMarried.ToList()[1].Value, result.IsMarried.ToList()[1].Value);
Assert.AreEqual(employee.Childs[0].Id, result.Childs[0].Id);
Assert.AreEqual(employee.Childs[1].Id, result.Childs[1].Id);
Assert.AreEqual(employee.BirthDate.ToList()[0].Key, result.BirthDate.ToList()[0].Key);
Assert.AreEqual(employee.BirthDate.ToList()[1].Key, result.BirthDate.ToList()[1].Key);
Assert.AreEqual(employee.BirthDate.ToList()[0].Value, result.BirthDate.ToList()[0].Value);
Assert.AreEqual(employee.BirthDate.ToList()[1].Value, result.BirthDate.ToList()[1].Value);
Assert.AreEqual(employee.YearlyIncome.ToList()[0].Key, result.YearlyIncome.ToList()[0].Key);
Assert.AreEqual(employee.YearlyIncome.ToList()[1].Key, result.YearlyIncome.ToList()[1].Key);
Assert.AreEqual(employee.YearlyIncome.ToList()[0].Value, result.YearlyIncome.ToList()[0].Value);
Assert.AreEqual(employee.YearlyIncome.ToList()[1].Value, result.YearlyIncome.ToList()[1].Value);
Assert.AreEqual(employee.FavoriteColor.ToList()[0].Key, result.FavoriteColor.ToList()[0].Key);
Assert.AreEqual(employee.FavoriteColor.ToList()[1].Key, result.FavoriteColor.ToList()[1].Key);
Assert.AreEqual(employee.FavoriteColor.ToList()[0].Value, result.FavoriteColor.ToList()[0].Value);
Assert.AreEqual(employee.FavoriteColor.ToList()[1].Value, result.FavoriteColor.ToList()[1].Value);
Assert.AreEqual(employee.Height.ToList()[0].Key, result.Height.ToList()[0].Key);
Assert.AreEqual(employee.Height.ToList()[1].Key, result.Height.ToList()[1].Key);
Assert.AreEqual(employee.Height.ToList()[0].Value, result.Height.ToList()[0].Value);
Assert.AreEqual(employee.Height.ToList()[1].Value, result.Height.ToList()[1].Value);
Assert.AreEqual(employee.Tall.ToList()[0].Key, result.Tall.ToList()[0].Key);
Assert.AreEqual(employee.Tall.ToList()[1].Key, result.Tall.ToList()[1].Key);
Assert.AreEqual(employee.Tall.ToList()[0].Value, result.Tall.ToList()[0].Value);
Assert.AreEqual(employee.Tall.ToList()[1].Value, result.Tall.ToList()[1].Value);
database.Command("DELETE FROM " + DemoEmployeeClassName + " WHERE Id = '" + employee.Id + "'");
}
}
Seems there is error in mapping in class Orient.Client.Mapping.DateTimeFieldMapping if object contains DateTime fields
Code fragments:
....
class File
{
public String fileName { get; set; }
public DateTime created { get; set; }
}
...
using (ODatabase database = new ODatabase(DBNAME))
{
database.Create.Class<File>().Extends<OVertex>().CreateProperties().Run();
}
When inserting exception appears:
System.InvalidCastException was unhandled
HResult=-2147467262
Message=Unable to cast object of type 'System.DateTime' to type 'System.String'.
Source=Orient.Client
StackTrace:
at Orient.Client.ODocument.GetField[T](String fieldPath) in c:\Temp\OrientDB\Orient.Client\API\Types\ODocument.cs:line 169
at Orient.Client.Mapping.DateTimeFieldMapping`1.MapToNamedField(ODocument document, TTarget typedObject) in c:\Temp\OrientDB\Orient.Client\Mapping\DateTimeFieldMapping.cs:line 20
at Orient.Client.Mapping.NamedFieldMapping`1.MapToObject(ODocument document, TTarget typedObject) in c:\Temp\OrientDB\Orient.Client\Mapping\FieldMapping.cs:line 65
at Orient.Client.Mapping.FieldMapping`1.MapToObject(ODocument document, Object typedObject) in c:\Temp\OrientDB\Orient.Client\Mapping\FieldMapping.cs:line 46
at Orient.Client.Mapping.TypeMapper`1.ToObject(ODocument document, T typedObject) in c:\Temp\OrientDB\Orient.Client\Mapping\TypeMapper.cs:line 157
at Orient.Client.ODocument.ToObject[T](T genericObject, String path) in c:\Temp\OrientDB\Orient.Client\API\Types\ODocument.cs:line 326
at Orient.Client.ODocument.To[T]() in c:\Temp\OrientDB\Orient.Client\API\Types\ODocument.cs:line 301
at Orient.Client.ORecordCreateVertex.Run[T]() in c:\Temp\OrientDB\Orient.Client\API\Query\ORecordCreateVertex.cs:line 129
at OrientDBTest.Program.Main(String[] args) in c:\TFS\NGP\NTT\Main\Auxillary\OrientDBTest\Program.cs:line 71
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
At this moment changing class to following code helps
namespace Orient.Client.Mapping
{
internal class DateTimeFieldMapping<TTarget> : BasicNamedFieldMapping<TTarget>
{
public DateTimeFieldMapping(PropertyInfo propertyInfo, string fieldPath)
: base(propertyInfo, fieldPath)
{
}
protected override void MapToNamedField(ODocument document, TTarget typedObject)
{
DateTime dateTime = document.GetField<DateTime>(_fieldPath);
SetPropertyValue(typedObject, dateTime);
}
}
}
Hi GoorMoon,
Whenever this is a sub class which is null, system will throw error. Even if it is not null but string is empty, it will throw null also. I have fixed the issue and will create a pull request for this. Thanks.
Cordially,
Goh
Recently @GoorMoon you have implanted the prepared sql method for Selecting documents(querying), it would be quite useful if you can implant the method for creating documents.
Github doesn't index forked repos for search and it would be nice to search this repo on Github. Since this fork is now the official C# client it seems appropriate to break the dependency to workshare/OrientDB-NET.binary by converting it to a normal repo.
My system is German with German region settings and I just encountered the following issue when trying to do inserts fields of type float:
Database db = new Database("myPool");
...
float myFloat = 108,4; // Germany uses , as decimal seperator
string someValue = "some";
...
ODocument doc = new ODocument();
doc.SetField<float>("myFloat", myFloat);
doc.SetField<string>("someValue", someValue);
...
db.Insert(doc);
Which results in a invalid INSERT statement like this:
INSERT INTO myTable SET myFloat = 108,4, someValue = 'some'
I also tried declaring the float
float myFloat = 108.4;
Which did not change the SQL statement generated.
UPDATE:
Okay, I changed my system settings to English now, everything except the UI language and the error persists. So it seems to me this is no region specific issue, like when I first encountered it.
Hello !
This small test is failing. The string 'e=mc2' become 'e:mc2' if stored in a member of an inner document
public void InsertColonAndEqualSymbolInInnerDocument()
{
Utils.InitPool();
using (ODatabase database = new ODatabase("alias"))
{
DataSourceOrientDbDTO entity = new DataSourceOrientDbDTO();
entity.Parameters = new List<DataSourceOrientDbDTO.DataSourceParameter>();
entity.Parameters.Add(new DataSourceOrientDbDTO.DataSourceParameter() { Name = "'e=mc2'" }); //Name property type is string
ODocument d = database.Insert<DataSourceOrientDbDTO>(entity).Run();
List<DataSourceOrientDbDTO> result = database
.Select()
.From(typeof(DataSourceOrientDbDTO).Name)
.Where("@rid").Equals(d.ORID)
.ToList<DataSourceOrientDbDTO>();
Assert.AreEqual("'e=mc2'", result.First().Parameters.First().Name); //returns \'e:mc2\'
}
}
A working solution for the column problem (but I don't know if there are side effects).
In SQLQuery.cs add an assignmentKeyword parameter to BuildFieldValue
private string BuildFieldValue<T>(string fieldName, T fieldValue, string assignmentKeyword)
{
string field = "";
if (_compiler.HasKey(Q.Set))
{
field += ", ";
}
field += string.Join(" ", fieldName, assignmentKeyword, ""); //was Q.Equals
From SQLQuery.ToString(), near "else if (value is ODocument)"
Original : var strValue = BuildFieldValue("'" + field.Key + "'", field.Value).Replace('=', ':');
New version : var strValue = BuildFieldValue("'" + field.Key + "'", field.Value, ":"); //assignmentKeyword should be ":" from THIS CALL ONLY
Other calls to BuildFieldValue should pass Q.Equals as assignmentKeyword (as currently in the code)
But I have no solution for the quotes problem
So i have a model, that stores a dictionary, it is part of the model, the storing process goes fine, no error, and when i get the data back it is also good. The problem happens when i store a dictionary with a single key pair value, then when i get it and try to convert it using the ODocuments to method it throws an exception ( 'System.Collections.Generic.KeyValuePair`2[System.String,System.Object]' to type 'System.Collections.IDictionary'. ). I checked the db.
It stored it as {"key":value},
Hi,
I always encounter connection reach max issues whereby I have ensured the connection has been closed for each usage by using the "using" keywords in c#. Below is the sample code,
using (var database = new ODatabase(databaseName))
{
// logic is here
}
I even tried to close the server connection each time by calling Server.Close(). It happens occasionally for the unit test cases. but it is alright sometime. But when it go to production testing, it always crash. Am I doing something wrong?
Thanks.
Cordially,
Goh
I am trying to create an extension method which, given a model object, will create vertices and edges between those vertices so that the model is accurately represented in the graph. For example, the models:
Person
string FirstName
string LastName
Address Residence
Address Shipping
Dependent : Person
int Relationship
Address
string AddressLine1
string AddressLine2
Person Resident
Creating a record with a Dependent object would be, essentially:
create vertex Dependent content {...}
create vertex Address content {...}
create vertex Address content {...}
create edge ResidenceAddress from ... to ...
create edge ShippingAddress from ... to ...
However, when I use OTransaction#Add
to create these records, my heavyweight edges are not connected to my vertices. All of my vertices are created with their properties set correctly, and all of my edges are created wit their properties set correctly (including out
and in
), but the vertices can't see their edges.
I can apparently replicate this same behavior within the OrientDB studio using insert into ...
instead of create edge ...
According to RobinG in a response to my SO question about this, the OTransaction class is incomplete, so I began attempting to add to the library so that I could get heavyweight edges working with transactions properly. However, my understanding of the binary interface is limited, and I've run into a wall.
Its more a question than issue
I want to use Orient in mixed mode. Somewhere I use ODocument queries, somewhere I use object updates for same documents etc
So at this moment I know some ORID and want to update object behind it.
{code}
String query = String.Format("select from {0} where ...");
documents = db.Query(query);
ODocument orientdoc = documents.FirstOrDefault();
{code}
And now I want to update the object that stands behind this doc using construction below. I actuallywant to replace its current value to a completely new data from just created instance)
{code}
int documentUpdated = db.Update(some_class_object).Run();
{code}
It throws NullPointer exception because id doesn't know ORID. How can I set existing ORDI to some new object instance?
Thanks in advance!
Hi,
I couldn't find the is class exist method. May I know how to check the existence of the class? Thanks.
Cordially,
Goh
Hi,
Is there anyway for us to get all the classes available in the database?
Cordially,
Goh
Hi,
I found another issue with handling dates. I have a class that contains a field of type Date and of course I need to write and read this value, but the written and read values do not match. Here is some sample code:
using (var db = new Database("mydbpool")
{
var doc = new ODocument { OClassName = "myClass" };
doc.SetField<DateTime>("Date", new DateTime(2015, 02, 08));
var retval = db.Insert(doc).Run();
var readDate = retval.GetField<DateTime>("Date");
}
You would expect that readDate matches "new DateTime(2015, 02, 08)", but it comes out 2015/02/07.
The value of 2015/02/08 is stored to the Database correctly. During the process of reading the date the value gets altered.
I am using the document model here.
[UPDATE1]
The actual value returned in the ODocument is only off by -1 hour. Of course when you are only looking at the date, you are off by -1 day. So somewhere this hour gets lost. Perhaps again some issue with the Java -> .Net conversion?
[UPDATE2]
I figured that it might be related to some UTC conversion issues, since I am located in Germany and my system is UTC+1. So I set my system to GMT/UTC time zone and to UK regional settings. But the offset still persists.
Hi,
While I was looking at parameters support in the driver, I was wondering why there was a check for CommandPayloadCommand in OCommandQuery.Set method? I tried to serialize an ODocument with a single field "params" that contained a Dictionary<string, object> and it worked. I am using OrientDB 1.7.8, protocol 21.
I also slighty modified the RecordCSVSerializer.SerializeObjectValue method to make sure some values are treated as a string in the map format. I don't know if it was previously an issue?
I also added a SqlBatch method that works with the parameters (I pass the parameters directly to the method on ODatabase and I added a "FromDictionary" method on the OCommandQuery so that it "Set" itself from all values in the dictionary. However I did not make a variant for numeric parameters.
Let me know if you're interested in pulls.
Hello !
This small test is failing because when saving, Object members values are lost (not stored in Db)
I don't understand why in the driver code. This is possible with CouchDb (Hammock driver) and MongoDb. Hammock serializes directly C# objects to JSON for storage (with JSON.Net)
[Test]
public void InsertWithObjectMember()
{
Utils.InitPool();
using (ODatabase database = new ODatabase("alias"))
{
EntityOrientDbDTO entity = new EntityOrientDbDTO();
entity.Data = "'e=mc2'"; //Data member type is Oject
ODocument d = database.Insert<EntityOrientDbDTO>(entity).Run();
List<EntityOrientDbDTO> result = database
.Select()
.From(typeof(EntityOrientDbDTO).Name)
.Where("@rid").Equals(d.ORID)
.ToList<EntityOrientDbDTO>();
Assert.AreEqual("'e=mc2'", result.First().Data); //result.First().Data.GetType() {Name = "Object" FullName = "System.Object"} System.Type {System.RuntimeType}
}
}
If I run the Orient.Console Program (and similar connection code in my own test program), the connection hangs. Debugging shows that Connection.ExecuteOpertion hangs in the line response.Receiver(). The server is up and running:
2015-03-28 15:28:34:743 INFO Listening binary connections on 127.0.0.1:2424 (pr
otocol v.28, socket=default) [OServerNetworkListener]
2015-03-28 15:28:34:744 INFO Listening http connections on 127.0.0.1:2480 (prot
ocol v.10, socket=default) [OServerNetworkListener]
The connection code is unmodified:
private static string _hostname = "localhost";
private static int _port = 2424;
private static string _username = "admin";
private static string _password = "admin";
private static string _rootUserName = "root";
private static string _rootUserParssword = "root";
private static OServer _server;
public static int GlobalTestDatabasePoolSize { get { return 3; } }
public static string GlobalTestDatabaseName { get; private set; }
public static ODatabaseType GlobalTestDatabaseType { get; private set; }
public static string GlobalTestDatabaseAlias { get; private set; }
static TestConnection()
{
_server = new OServer(_hostname, _port, _rootUserName, _rootUserParssword);
.
Please view orientDB repository issue #3556
Apparently having log off in transactions
request.AddDataItem((byte)0); // use log 0 = no, 1 = yes
can lead the DB to an inconsistent state.
I receive the following unhandled exception when run the console application code https://github.com/orientechnologies/OrientDB-NET.binary/blob/master/src/Orient/Orient.Console/Program.cs . Specifically, when the code tries to create a vertex at line 28. I receive the exception when the code runs against both versions v1.711-snapshot and v2.0-rc1.
Orient.Client.OException was unhandled
HResult=-2146233088
Message=Cannot write to a BufferedStream while the read buffer is not empty if the underlying stream is not seekable. Ensure that the stream underlying this BufferedStream can seek or avoid interleaving read and write operations on this BufferedStream.
Source=Orient.Client
StackTrace:
at Orient.Client.Protocol.Connection.Send(Byte[] rawData) in c:\data\training\training\OrientDB-NET.binary-master\src\Orient\Orient.Client\Protocol\Connection.cs:line 265
at Orient.Client.Protocol.Connection.ExecuteOperation(IOperation operation) in c:\data\training\training\OrientDB-NET.binary-master\src\Orient\Orient.Client\Protocol\Connection.cs:line 104
at Orient.Client.ORecordCreateVertex.Run() in c:\data\training\training\OrientDB-NET.binary-master\src\Orient\Orient.Client\API\Query\ORecordCreateVertex.cs:line 122
at Orient.Console.Program.Main(String[] args) in c:\data\training\training\OrientDB-NET.binary-master\src\Orient\Orient.Console\Program.cs:line 33
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
According to this post, prepared sql is supported:
https://groups.google.com/forum/#!msg/orient-database/sytdxVTwk_w/zAR12xjZlhUJ
Can this be supported through the .NET client?
Running latest, attempt to run either console or any unit test OrientDB server never responds to connection request, causing client to hang indefinitely waiting for a response:
Connection.cs Line 248
Document = ExecuteOperation(operation);
Inbound socket connection is created, but the server never responds.
I have 3 nodes in a cluster.
I connect to node 1 and create some connected nodes. I then connect to node 2 and try to create some other nodes using the same classes but I get an error saying
com.orientechnologies.orient.server.distributed.ODistributedException: Error on inserting into cluster 'country' where local node 'node2' is not the master of it, but it's 'node1'
I noticed that ODatabase method GetClusterIdFor always returns the same Id independent of which machine I am connected to.
Error will be thrown whenever property type is List
Hi,
I have done some unit test on List and seems like no data is will be able to retrieve. No problem on insert but while retrieve it doesn't get through for the property Child
var employeeListTypeClassName = "EmployeeListType";
var employee = new EmployeeListType();
employee.Id = Guid.NewGuid();
employee.Name = new List();
employee.Name.Add("Andrew");
employee.Name.Add("Jack");
employee.Age = new List();
employee.Age.Add(1);
employee.Age.Add(2);
employee.BirthDate = new List();
employee.BirthDate.Add(DateTime.Now);
employee.BirthDate.Add(DateTime.Now.AddDays(-3));
employee.Childs = new List();
employee.Childs.Add(new EmployeeCommonType() { Id = Guid.NewGuid() });
employee.Childs.Add(new EmployeeCommonType() { Id = Guid.NewGuid() });
employee.FavoriteColor = new List();
employee.FavoriteColor.Add(Color.Red);
employee.FavoriteColor.Add(Color.Blue);
employee.Height = new List();
employee.Height.Add(323);
employee.Height.Add(333);
employee.Ids = new List();
employee.Ids.Add(Guid.NewGuid());
employee.Ids.Add(Guid.NewGuid());
employee.IsMarried = new List();
employee.IsMarried.Add(true);
employee.IsMarried.Add(false);
employee.Salary = new List();
employee.Salary.Add((decimal)1234567890.123456789);
employee.Salary.Add((decimal)1234567890.123456799);
employee.Tall = new List();
employee.Tall.Add(3233);
employee.Tall.Add(3234);
employee.YearlyIncome = new List();
employee.YearlyIncome.Add(3233);
employee.YearlyIncome.Add(1234);
// My wrapper for OrientDB insert
writer.Insert<EmployeeListType>(employee, DatabaseName, employeeListTypeClassName);
// My wrapper to create connection Pool
dbProvider.CreateConnectionPool(DatabaseName);
using (var database = new ODatabase(DatabaseName))
{
var result = database.Query<EmployeeListType>("SELECT * FROM " + employeeListTypeClassName + " WHERE Id = '" + employee.Id + "'").SingleOrDefault();
Assert.AreEqual(employee.Id, result.Id);
Assert.AreEqual(employee.Ids[0], result.Ids[0]);
Assert.AreEqual(employee.Ids[1], result.Ids[1]);
Assert.AreEqual(employee.Name[0], result.Name[0]);
Assert.AreEqual(employee.Name[1], result.Name[1]);
Assert.AreEqual(employee.Age[0], result.Age[0]);
Assert.AreEqual(employee.Age[1], result.Age[1]);
Assert.AreEqual(employee.Age[0], result.Age[0]);
Assert.AreEqual(employee.Salary[0], result.Salary[0]);
Assert.AreEqual(employee.Salary[1], result.Salary[1]);
Assert.AreEqual(employee.IsMarried[0], result.IsMarried[0]);
Assert.AreEqual(employee.IsMarried[1], result.IsMarried[1]);
// Error happen here.
Assert.AreEqual(employee.Childs[0].Id, result.Childs[0].Id);
Assert.AreEqual(employee.Childs[1].Id, result.Childs[1].Id);
Assert.AreEqual(employee.BirthDate[0].ToLongDateString(), result.BirthDate[0].ToLongDateString());
Assert.AreEqual(employee.BirthDate[1].ToLongDateString(), result.BirthDate[1].ToLongDateString());
Assert.AreEqual(employee.YearlyIncome[0], result.YearlyIncome[0]);
Assert.AreEqual(employee.YearlyIncome[1], result.YearlyIncome[1]);
Assert.AreEqual(employee.FavoriteColor[0], result.FavoriteColor[0]);
Assert.AreEqual(employee.FavoriteColor[1], result.FavoriteColor[1]);
Assert.AreEqual(employee.Height[0], result.Height[0]);
Assert.AreEqual(employee.Height[1], result.Height[1]);
Assert.AreEqual(employee.Tall[0], result.Tall[0]);
Assert.AreEqual(employee.Tall[1], result.Tall[1]);
}
Hi,
I have done some testing on the insert but I encountered number of issues and would like to lodge a reports.
Apart from the issues listed. The data type is not similar and the figure had been rounded up as well. Attached here with the screenshot and the original source code.
public static void TestOrientDBObjectTypeSupported()
{
var GlobalTestDatabaseName = "TestDatabaseName";
var GlobalTestDatabaseType = ODatabaseType.Graph;
var GlobalTestDatabaseAlias = "TestDatabaseNameAlias";
_server = new OServer(_hostname, _port, _rootUserName, _rootUserParssword);
//if (_server.DatabaseExist(GlobalTestDatabaseName, OStorageType.PLocal))
//{
// _server.DropDatabase(GlobalTestDatabaseName, OStorageType.PLocal);
//}
//_server.CreateDatabase(GlobalTestDatabaseName, GlobalTestDatabaseType, OStorageType.PLocal);
OClient.CreateDatabasePool(
_hostname,
_port,
GlobalTestDatabaseName,
GlobalTestDatabaseType,
_username,
_password,
10,
GlobalTestDatabaseAlias
);
DateTime startTime = DateTime.Now;
Console.WriteLine("Start Time: " + startTime.ToLongTimeString());
using (ODatabase database = new ODatabase("TestDatabaseNameAlias"))
{
var employee = new DemoEmployee();
employee.Name = "Janet";
employee.Age = 33;
employee.SomeVeryLongNumber = 12345678901234567;
employee.BirthDate = new DateTime(2015, 1, 24, 2,2,2);
employee.Salary = (decimal)23434.1234567891;
employee.Commission = (double)23434.1234567891;
employee.Allowance = (float)3434.1234567891;
employee.IsMarried = true;
employee.SomeIntegerList = new List<int>();
employee.SomeIntegerList.Add(1);
employee.SomeIntegerList.Add(2);
employee.SomeIntegerList.Add(3);
employee.SomeIntegerArrayList = new int[3] { 4, 2, 3 };
employee.SomeDecimalList = new List<decimal>();
employee.SomeDecimalList.Add((decimal)23434.1234567891);
employee.SomeDecomeArray = new decimal[3] { (decimal)23434.1234567890, (decimal)23434.1234567890, (decimal)23434.1234567890 };
employee.Kids = new List<DemoChild>();
var kid = new DemoChild();
kid.Name = "Janet";
kid.Age = 33;
kid.SomeVeryLongNumber = 12345678901234567;
kid.BirthDate = new DateTime(2015, 1, 24, 2, 2, 2);
kid.Salary = (decimal)23434.1234567891;
kid.Commission = (double)23434.1234567891;
kid.Allowance = (float)3434.1234567891;
kid.IsMarried = true;
kid.SomeIntegerList = new List<int>();
kid.SomeIntegerList.Add(1);
kid.SomeIntegerList.Add(2);
kid.SomeIntegerList.Add(3);
kid.SomeIntegerArrayList = new int[3] { 4, 2, 3 };
kid.SomeDecimalList = new List<decimal>();
kid.SomeDecimalList.Add((decimal)23434.1234567891);
kid.SomeDecomeArray = new decimal[3] { (decimal)23434.1234567890, (decimal)23434.1234567890, (decimal)23434.1234567890 };
employee.Kids.Add(kid);
//employee.SomeIListInteger = new List<int>();
//employee.MyKeyValues = new Dictionary<int, string>();
//employee.MyKeyValues.Add(1, "Name");
//employee.SomeIListInteger.Add(7);
database.Insert<DemoEmployee>(employee).Run();
}
DateTime endTime = DateTime.Now;
TimeSpan duration = endTime - startTime;
Console.WriteLine("End Time: " + endTime.ToLongTimeString());
Console.WriteLine("Total time taken: " + duration.TotalSeconds);
}
public class DemoChild
{
public string Name { get; set; }
public int Age { get; set; }
public long SomeVeryLongNumber { get; set; }
public decimal Salary { get; set; }
public double Commission { get; set; }
public float Allowance { get; set; }
public DateTime BirthDate { get; set; }
public bool IsMarried { get; set; }
public List<int> SomeIntegerList { get; set; }
public int[] SomeIntegerArrayList { get; set; }
public List<decimal> SomeDecimalList { get; set; }
public decimal[] SomeDecomeArray { get; set; }
}
public class DemoEmployee
{
//public Guid SomeOtherId { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public long SomeVeryLongNumber { get; set; }
public decimal Salary { get; set; }
public double Commission { get; set; }
public float Allowance { get; set; }
public DateTime BirthDate { get; set; }
public bool IsMarried { get; set; }
public List<int> SomeIntegerList { get; set; }
public int[] SomeIntegerArrayList { get; set; }
public List<decimal> SomeDecimalList { get; set; }
public decimal[] SomeDecomeArray { get; set; }
public List<DemoChild> Kids { get; set; }
//public IList<int> SomeIListInteger { get; set; }
//public Dictionary<int, string> MyKeyValues { get; set; }
// public Color MyFavoriteColor { get; set; }
//public enum Color
//{
// Blue, Red
//}
}
Hi,
My colleague encountered a problem whenever he tried to retrieve an object with one of the property was null. He figure out the null object was being instantiated. The bug has been fixed by him at cychua2015@6bfe04e. Please merge and we shall test again thereafter. Thanks.
Cordially,
Goh
Here is what I have done so far to try and debug retrieved values:
document = db.Query("select from interventi limit 10");
foreach (ODocument singleDoc in document)
{
List<ORID> orids = singleDoc.GetField<List<ORID>>("out_InterventoICD");
foreach(ORID rid in orids)
{
lblResults.Text += rid.ToString() + ",";
}
lblResults.Text += "<br />";
string relationTypes = singleDoc.GetField<string>("@fieldTypes");
lblResults.Text += relationTypes;
}
If I use REST protocol I can retrieve the list of fields with related type correctly but the binary driver instead seems to not return any value. From REST response it looks like @fieldTypes should be a string. I have anyway tried to retrieve it the following way to no avail.
List relationTypes = singleDoc.GetField<List>("@fieldTypes");
Being @fieldTypes a special internal field such as ORID, OType, OVersion, I would expect a specific method in the driver to retrieve it but it doesn't seem to exist.
Am I missing something?
Was trying to create class with list or enumerable property and are getting this error.
You can easily replicate it by modifying the test case like that.
public class GitHub_issue38
{
[Test]
public void ShouldCreateRecordContainingSingleQuote()
{
using (TestDatabaseContext testContext = new TestDatabaseContext())
using (var db = new ODatabase(TestConnection.GlobalTestDatabaseAlias))
{
if (!db.Schema.IsClassExist<TestClass>())
{
db.Create.Class<TestClass>().CreateProperties<TestClass>().Run();
}
db.Command("delete from TestClass");
var text = @"Jim'n";
var test = new TestClass() { SomeString = text };
db.Insert(test).Run();
var result = db.Select().From<TestClass>().ToList<TestClass>();
Assert.AreEqual(text, result.Single().SomeString);
}
}
public class TestClass
{
public TestClass()
{
}
public List<string> SomeList { get; set; }
public string SomeString { get; set; }
}
}
Related to:
orientechnologies/orientdb#1275
Just came across the issue with single quotes while importing data using the .NET Driver from another DBMS to OrientDB. The occurrence of single quotes in strings lead to parsing errors. I manually used the \' convention to replace the single quotes, but this should be handled by the driver.
I would like to see you support LINQ the standard way in C# to work with data: Linq2Objects for data in memory and Linq2SQL through different ORMs. So different sources but the same language to work with them.
Under a commercial view point it is as smart as your decission of supporting SQL. We all have Apps in .NET based on NHibernate or Entity Framework which use LINQ for accessing SQL bds. Indeed now for me is difficult to think in a project with relational databases involved where an ORM is not used. So if you want to make it easy we move to your db, best would be offer a LINQ API. Even better than this would be you offer an Entity Framework 7 provider. This version of this ORM will support SQL and NOSQL DBS so it will make easier to devs to change from a relational db to a non relational one.
Problem of ORMs with LINQ is the high cost of transforming LINQ to SQL. They solve it caching compiled queries. Problem happens specially with dynamic LINQ queries (those you would do it concatenating strings if you were writing SQLs). Dynamic LINQ ones can't be cached.
And those ones are the ones programmers would prefer to use if they could forget of performance.
The other problem of ORMs is they don't produce optimal SQL queries.
So devs despite we would love to use LINQ and dynamic LINQ because it is a typed language and it heps us to avoid typos and saves us of a lot of extra work. We use SQL for complex queries and avoid dynamic LINQ ones.
The point is the bottleneck is LINQ2SQL. As far as I understand LINQ2GraphDB won't be a bottle neck. Why? Because LINQ is an extensible language for manage objects, it is OO language. The gap between OO and relational DBs is bigger than the gap between OO and graph dbs. So, this gap won't be a problem for a graph db like for a relational one.
If you finally offer a LINQ2Graphdb driver we would be able to use LINQ for complex queries and dynamic LINQ without be worried of the performance hit it could cause.
Regards
The setter should be removed in ORID.RID. This means that a RID cannot be overwritten. Id's should be immutable and never modifiable. It also makes RID consistent as there is no other assignment operator on ORID. Also RID should be changed to Rid. Actually I would eliminate RID and support ToString() to make it consistent with .NET conformance. And since ORIDs are no larger than a GUID, would consider making ORIDs a value type over a class type. This would also go to making ORIDs immutable. Take a look at how the Guid value type is defined and model the Orid value type around that.
A query with a fetchplan does not properly fetch linked documents. Instead only the ORID is retrieved.
I'll submit a test case.
Hi,
I find some common data type like short and long are not supported by the document.Query. Here's the sample.
var employee = new EmployeeCommonType();
employee.Id = Guid.NewGuid();
employee.Name = "Goh";
employee.Age = 33;
employee.Salary = (decimal)123456789.123456789;
employee.IsMarried = true;
employee.BirthDate = DateTime.Now;
employee.Tall = 123;
employee.Height = 123;
using (var database = new ODatabase(databaseName))
{
database.Insert(employee)
.Into(className)
.Run();
var result = database.Query<EmployeeCommonType>("SELECT * FROM " + className + " WHERE Id = '" + employee.Id + "'").SingleOrDefault();
Assert.AreEqual(employee.Id, result.Id);
Assert.AreEqual(employee.Name, result.Name);
Assert.AreEqual(employee.Age, result.Age);
Assert.AreEqual(employee.Salary, result.Salary);
Assert.AreEqual(employee.IsMarried, result.IsMarried);
Assert.AreEqual(employee.BirthDate.ToLongDateString(), result.BirthDate.ToLongDateString());
Assert.AreEqual(employee.YearlyIncome, result.YearlyIncome);
Assert.AreEqual(employee.Height, result.Height);
Assert.AreEqual(employee.Tall, result.Tall);
database.Command("DELETE FROM " + className + " WHERE Id = '" + employee.Id + "'");
}
public class EmployeeCommonType
{
public Guid Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public decimal Salary { get; set; }
public bool IsMarried { get; set; }
public DateTime BirthDate { get; set; }
public double YearlyIncome { get; set; }
public short Height { get; set; }
public long Tall { get; set; }
}
When working with DateTime and setting values to its default value using default(DateTime) this results in a ArgumentOutOfRangeException. Here is the stack trace:
at System.DateTime.AddTicks(Int64 value)
at Orient.Client.Protocol.Serializers.RecordCSVSerializer.ParseValue(Int32 i, String recordString, ODocument document, String fieldName) in ..\OrientDB-NET.binary\src\Orient\Orient.Client\Protocol\Serializers\RecordCSVSerializer.cs:Line 523.
at Orient.Client.Protocol.Serializers.RecordCSVSerializer.ParseFieldName(Int32 i, String recordString, ODocument document) in ..\OrientDB-NET.binary\src\Orient\Orient.Client\Protocol\Serializers\RecordCSVSerializer.cs:Line 300.
at Orient.Client.Protocol.Serializers.RecordCSVSerializer.Deserialize(String recordString, ODocument document) in ..\OrientDB-NET.binary\src\Orient\Orient.Client\Protocol\Serializers\RecordCSVSerializer.cs:Line 62.
at Orient.Client.Protocol.Serializers.RecordCSVSerializer.Deserialize(Byte[] rawRecord, ODocument document) in ..\OrientDB-NET.binary\src\Orient\Orient.Client\Protocol\Serializers\RecordCSVSerializer.cs:Line 77.
at Orient.Client.Protocol.Operations.Command.Command.ParseDocument(BinaryReader reader) in ..\OrientDB-NET.binary\src\Orient\Orient.Client\Protocol\Operations\Command\Command.cs:Line 217.
at Orient.Client.Protocol.Operations.Command.Command.Response(Response response) in ..\OrientDB-NET.binary\src\Orient\Orient.Client\Protocol\Operations\Command\Command.cs:Line 143.
at Orient.Client.Protocol.Connection.ExecuteOperation(IOperation operation) in ..\OrientDB-NET.binary\src\Orient\Orient.Client\Protocol\Connection.cs:Line 129.
at Orient.Client.OSqlInsert.Run() in ..\OrientDB-NET.binary\src\Orient\Orient.Client\API\Query\OSqlInsert.cs:Line 113.
From what I could see it is caused by the conversion to UNIX timestamp. I currently do not have the time to investigate, but at the point where the DateTime field is converted to UNIX Timestamp there should be a check if the field value matches default(DateTime).
Revision used: master 5102043
Quick update:
Insert operations succeeded despite those exceptions being thrown.
I have used your code on SO
var v1 = new ODocument { OClassName = "TestVertex" };
v1.SetField("Name", "First");
v1.SetField("Bar", 1);
var v2 = new ODocument { OClassName = "TestVertex" };
v2.SetField("Name", "Second");
v2.SetField("Bar", 2);
var e1 = new ODocument { OClassName = "TestEdge" };
e1.SetField("Weight", 1.3f);
// Add records to the transaction
database.Transaction.Add(v1);
database.Transaction.Add(v2);
database.Transaction.Add(e1);
// link records
v1.SetField("in_TestEdge", e1.ORID);
v2.SetField("out_TestEdge", e1.ORID);
e1.SetField("in", v1.ORID);
e1.SetField("out", v2.ORID);
database.Transaction.Commit();
but it will fail to "link" a new record if you want to Create another edge of that class
Hello,
So far everything is perfect with OrientDB during testing, except one fact.
With .Net connector, current master branch, inside a transaction,
we have identified a scenario which corrupted the database.
First, this scenario is OK:
/* Create 2 vertices 1 and 2 */
var v1 = new OVertex { OClassName = "MY_ENTITY" };
v1.SetField("UUID", "Hello 1");
v1.SetField("Name", "First");
var v2 = new OVertex { OClassName = "MY_ENTITY" };
v2.SetField("UUID", "Hello 2");
v2.SetField("Name", "Second");
CRUDService.CurrentODB.Transaction.Add(v1);
CRUDService.CurrentODB.Transaction.Add(v2);
/* Create Edge between these vertices */
var e1 = new OEdge { OClassName = "MY_LINK" };
e1.SetField("UUID", "Hello 3");
CRUDService.CurrentODB.Transaction.Add(e1);
v1.SetField("in_MY_LINK", e1.ORID);
v2.SetField("out_MY_LINK", e1.ORID);
e1.SetField("in", v1.ORID);
e1.SetField("out", v2.ORID);
/* Commit transaction */
CRUDService.CurrentODB.Transaction.Commit();
But in this specific scenario, with a delete(vertex 1) command
var obj = GetVertex("Hello 1");
CRUDService.CurrentODB.Transaction.Delete(obj);
CRUDService.CurrentODB.Transaction.Commit();
At this step, Vertex 1 is deleted but not the Edge (so no cascading like without transaction?).
When we try to delete Edge with OrientDb Studio we have an NullPointException:
2015-06-18 11:07:44:666 SEVERE Internal server error:
java.lang.NullPointerException [ONetworkProtocolHttpDb]
We have to execute repair database:
orientdb {db=test_us_scenario}> repair database
Repairing database...
- Fixing dirty links...Done! Fixed links: 1, modified documents: 1
Repair database complete (0 errors)
orientdb {db=test_us_scenario}>
Is it due to a missing or specific command we have to use?
Hi,
I have encountered an error for Dictionary type. Here's the code
[Test]
public void GIVEN___EmployeeDictionaryType_class_with_common_data_type___WHEN___write_to_orientdb___THEN___should_be_able_to_read()
{
var employeeClassName = "EmployeeDictionaryType";
var employee = new EmployeeDictionaryType();
employee.Id = Guid.NewGuid();
employee.Name = new Dictionary<string, string>();
employee.Name.Add("Andrew", "Andrew");
employee.Name.Add("Jack", "Jack");
employee.Age = new Dictionary<int, int>();
employee.Age.Add(1, 2);
employee.Age.Add(2, 4);
employee.BirthDate = new Dictionary<DateTime, DateTime>();
employee.BirthDate.Add(DateTime.Now, DateTime.Now.AddDays(1));
employee.BirthDate.Add(DateTime.Now.AddDays(-3), DateTime.Now.AddDays(-2));
employee.Childs = new Dictionary<int, EmployeeCommonType>();
employee.Childs.Add(1, new EmployeeCommonType() { Id = Guid.NewGuid() });
employee.Childs.Add(2, new EmployeeCommonType() { Id = Guid.NewGuid() });
employee.FavoriteColor = new Dictionary<Color, Color>();
employee.FavoriteColor.Add(Color.Red, Color.Red);
employee.FavoriteColor.Add(Color.Blue, Color.Blue);
employee.Height = new Dictionary<short, short>();
employee.Height.Add(1, 323);
employee.Height.Add(2, 333);
employee.Ids = new Dictionary<Guid, Guid>();
employee.Ids.Add(Guid.NewGuid(), Guid.NewGuid());
employee.Ids.Add(Guid.NewGuid(), Guid.NewGuid());
employee.IsMarried = new Dictionary<bool, bool>();
employee.IsMarried.Add(true, true);
employee.IsMarried.Add(false, false);
employee.Salary = new Dictionary<decimal, decimal>();
employee.Salary.Add((decimal)1, (decimal)1234567890.123456789);
employee.Salary.Add((decimal)2, (decimal)1234567890.123456799);
employee.Tall = new Dictionary<long, long>();
employee.Tall.Add(1, 3233);
employee.Tall.Add(2, 3234);
employee.YearlyIncome = new Dictionary<double, double>();
employee.YearlyIncome.Add(2, 3233);
employee.YearlyIncome.Add(4, 1234);
//writer.Insert<EmployeeDictionaryType>(employee, DatabaseName, employeeClassName);
//dbProvider.CreateConnectionPool(DatabaseName);
using (var database = new ODatabase(DatabaseName))
{
database.Insert(employee)
.Into(employeeClassName)
.Run();
var result = database.Query<EmployeeDictionaryType>("SELECT * FROM " + employeeClassName + " WHERE Id = '" + employee.Id + "'").SingleOrDefault();
Assert.AreEqual(employee.Id, result.Id);
Assert.AreEqual(employee.Ids.ToList()[0].Key, result.Ids.ToList()[0].Key);
Assert.AreEqual(employee.Ids.ToList()[1].Key, result.Ids.ToList()[1].Key);
Assert.AreEqual(employee.Ids.ToList()[0].Value, result.Ids.ToList()[0].Value);
Assert.AreEqual(employee.Ids.ToList()[1].Value, result.Ids.ToList()[1].Value);
Assert.AreEqual(employee.Name.ToList()[0].Key, result.Name.ToList()[0].Key);
Assert.AreEqual(employee.Name.ToList()[1].Key, result.Name.ToList()[1].Key);
Assert.AreEqual(employee.Name.ToList()[0].Value, result.Name.ToList()[0].Value);
Assert.AreEqual(employee.Name.ToList()[1].Value, result.Name.ToList()[1].Value);
Assert.AreEqual(employee.Age.ToList()[0].Key, result.Age.ToList()[0].Key);
Assert.AreEqual(employee.Age.ToList()[1].Key, result.Age.ToList()[1].Key);
Assert.AreEqual(employee.Age.ToList()[0].Value, result.Age.ToList()[0].Value);
Assert.AreEqual(employee.Age.ToList()[1].Value, result.Age.ToList()[1].Value);
Assert.AreEqual(employee.Salary.ToList()[0].Key, result.Salary.ToList()[0].Key);
Assert.AreEqual(employee.Salary.ToList()[1].Key, result.Salary.ToList()[1].Key);
Assert.AreEqual(employee.Salary.ToList()[0].Value, result.Salary.ToList()[0].Value);
Assert.AreEqual(employee.Salary.ToList()[1].Value, result.Salary.ToList()[1].Value);
Assert.AreEqual(employee.IsMarried.ToList()[0].Key, result.IsMarried.ToList()[0].Key);
Assert.AreEqual(employee.IsMarried.ToList()[1].Key, result.IsMarried.ToList()[1].Key);
Assert.AreEqual(employee.IsMarried.ToList()[0].Value, result.IsMarried.ToList()[0].Value);
Assert.AreEqual(employee.IsMarried.ToList()[1].Value, result.IsMarried.ToList()[1].Value);
Assert.AreEqual(employee.Childs[0].Id, result.Childs[0].Id);
Assert.AreEqual(employee.Childs[1].Id, result.Childs[1].Id);
Assert.AreEqual(employee.BirthDate.ToList()[0].Key, result.BirthDate.ToList()[0].Key);
Assert.AreEqual(employee.BirthDate.ToList()[1].Key, result.BirthDate.ToList()[1].Key);
Assert.AreEqual(employee.BirthDate.ToList()[0].Value, result.BirthDate.ToList()[0].Value);
Assert.AreEqual(employee.BirthDate.ToList()[1].Value, result.BirthDate.ToList()[1].Value);
Assert.AreEqual(employee.YearlyIncome.ToList()[0].Key, result.YearlyIncome.ToList()[0].Key);
Assert.AreEqual(employee.YearlyIncome.ToList()[1].Key, result.YearlyIncome.ToList()[1].Key);
Assert.AreEqual(employee.YearlyIncome.ToList()[0].Value, result.YearlyIncome.ToList()[0].Value);
Assert.AreEqual(employee.YearlyIncome.ToList()[1].Value, result.YearlyIncome.ToList()[1].Value);
Assert.AreEqual(employee.FavoriteColor.ToList()[0].Key, result.FavoriteColor.ToList()[0].Key);
Assert.AreEqual(employee.FavoriteColor.ToList()[1].Key, result.FavoriteColor.ToList()[1].Key);
Assert.AreEqual(employee.FavoriteColor.ToList()[0].Value, result.FavoriteColor.ToList()[0].Value);
Assert.AreEqual(employee.FavoriteColor.ToList()[1].Value, result.FavoriteColor.ToList()[1].Value);
Assert.AreEqual(employee.Height.ToList()[0].Key, result.Height.ToList()[0].Key);
Assert.AreEqual(employee.Height.ToList()[1].Key, result.Height.ToList()[1].Key);
Assert.AreEqual(employee.Height.ToList()[0].Value, result.Height.ToList()[0].Value);
Assert.AreEqual(employee.Height.ToList()[1].Value, result.Height.ToList()[1].Value);
Assert.AreEqual(employee.Tall.ToList()[0].Key, result.Tall.ToList()[0].Key);
Assert.AreEqual(employee.Tall.ToList()[1].Key, result.Tall.ToList()[1].Key);
Assert.AreEqual(employee.Tall.ToList()[0].Value, result.Tall.ToList()[0].Value);
Assert.AreEqual(employee.Tall.ToList()[1].Value, result.Tall.ToList()[1].Value);
database.Command("DELETE FROM " + DemoEmployeeClassName + " WHERE Id = '" + employee.Id + "'");
}
}
public class EmployeeDictionaryType
{
public Guid Id { get; set; }
public Dictionary<Guid, Guid> Ids { get; set; }
public Dictionary<string, string> Name { get; set; }
public Dictionary<int, int> Age { get; set; }
public Dictionary<decimal, decimal> Salary { get; set; }
public Dictionary<bool, bool> IsMarried { get; set; }
public Dictionary<DateTime, DateTime> BirthDate { get; set; }
public Dictionary<double, double> YearlyIncome { get; set; }
public Dictionary<short, short> Height { get; set; }
public Dictionary<long, long> Tall { get; set; }
public Dictionary<Color, Color> FavoriteColor { get; set; }
public Dictionary<int, EmployeeCommonType> Childs { get; set; }
}
public class EmployeeCommonType
{
public Guid Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public decimal Salary { get; set; }
public bool IsMarried { get; set; }
public DateTime BirthDate { get; set; }
public double YearlyIncome { get; set; }
public short Height { get; set; }
public long Tall { get; set; }
public Color FavoriteColor { get; set; }
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.