Giter VIP home page Giter VIP logo

orientdb-net.binary's Introduction

Alpha Released of New Driver

https://github.com/orientechnologies/OrientDB.Net.Core

The .Net Driver has been completely overhauled and rewritten to follow modern standards in database driver patterns. Please test and add any issue to the new projects as we work to retire this implementation.


OrientDB-NET.binary is C#/.NET driver for OrientDB document/graph database which implements network binary protocol. For more information look at the Documentation.

Now Contains

  • Written in DNX Release 1 for DNX and .Net 4.5.1 support
  • Better handling of ordered edges
  • Support for LoadRecord and CreateRecord operations - faster than performing the same action via SQL commands
  • Improved mapping code for generic types to/from ODocuments - much faster, avoids repeated reflection
  • Support for fetch plans using LoadRecord to pull back a whole tree of objects in one request
  • Initial support for transactional create/update/delete - should be much faster than multiple individual SQL commands
  • Better support for derived types - .ToUnique will construct a TDerived if the database record is of type TDerived
  • Initial support for the OrientDB 2.2 binary protocol
  • Automatic schema creation from public properties of C# types (Database.Create.Class().CreateProperties().Run())

Fetching a large block of records from the DB via Database.Load.ORID(orid).FetchPlan(plan) and converting them to typed objects about 6 times faster than original code using SQL commands and old mapping.

Storing a large block of records into the DB via a transaction is about 10 times faster than doing it via individual SQL create statements.

How To Use

This code is still under active development.

For the latest build you can in the driver from NuGet

The unit tests should run cleanly and will start and stop OrientDB on the local machine themselves. You will likely need to change the values in the appsettings.json to point correctly to your local OrientDB install.

For more information look at the Documentation.

orientdb-net.binary's People

Contributors

calebbriggs avatar dagnarrus avatar gohsianghwee avatar goormoon avatar graydelacluyse avatar jakobt avatar kalmusr avatar lithl avatar lvca avatar realityenigma avatar rwg0 avatar ryantopps avatar sowee15 avatar stefanocastriotta avatar yojimbo87 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

orientdb-net.binary's Issues

Error for database.Insert<Type> for dictionary

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; }
}

database.Query<Type> error for array type.

[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; }
}

How could we add an edge to existing nodes without loading them first?

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.

Error when getting stored dictionary

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},

"Object" members lose their value when saved

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}

        }
    }

driver not fetching @fieldTypes

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?

Database Corruption after delete in transaction

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?

Connection reach max issue

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

Change this repo to normal instead of a fork.

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.

ReadByte issue with OrientDB 2.0rc

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.

edge can not be Created with Transaction

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

Should fetch linked document

A query with a fetchplan does not properly fetch linked documents. Instead only the ORID is retrieved.

I'll submit a test case.

{"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."}

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:

ODistributed exception caused by Cluster name mastership

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.

A number of common data type not supported

Hi,

I have done some testing on the insert but I encountered number of issues and would like to lodge a reports.

  1. GUID is not supported and will throw error.
  2. Enum type also not supported.
  3. IList is not supported
  4. Dictionary and SortedList is not supported
  5. List is also not supported

    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.

    snapshot1
    snapshot2

    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
        //}
    }
    

"Requested value 'none' was not found" exception on CreateDatabasePool

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)

Can't find cluster id if cluster name and class name are different

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.
default
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

OrientDB Server Accepts Connection Does Not Respond to Connect request

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.

default(DateTime) causes ArgumentOutOfRangeException

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.

List<Class> error for

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]);

        }

Consider making ORIDs immutable

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.

System.ArgumentException : propertyType List`1 is not yet supported.

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; }
    }
}

Connection problem

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);

.

Insert(ODocument) fails whith float values, because of , decimal seperator

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.

DateTime returned is off by -1 day

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.

How to get ORID of object?

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!

Sub class Error

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

Connection-Pool issue when database restarts

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

Problem inserting object with date time fields

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);

        }
    }
}

BaseOperation.EndOfStream() fails with NPE on Mono

@GoorMoon

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.

Creating vertices and (heavyweight) edges in a transaction

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.

Parameters

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.

Some data type not supported

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

Single quote escape convention

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.

Linq and Entity Framework 7 support

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

Error for database.Insert<Type> for sortedList

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 + "'");
        }
    }

Common Data type short and long not supported by database.Query

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; }


}

Colons and quotes lost when saved in a inner document

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.