I'm having trouble using properties of type decimal
in my program, which uses Neo4jClient to interact with my Neo4J server.
using System;
using Neo4jClient;
namespace TestProject
{
class Program
{
static void Main()
{
var graphClient = new GraphClient(new Uri("http://localhost:7474/db/data"));
graphClient.Connect();
const decimal socialFactor = 0.5m;
var userIn = new User {Name = "John Doe", SocialFactor = socialFactor};
var nodeRef = graphClient.Create(userIn);
var userOut = graphClient.Get(nodeRef).Data;
Console.WriteLine(userOut.Name + ", " + userOut.SocialFactor);
Console.WriteLine(userOut.SocialFactor == socialFactor ? "win" : "fail!");
}
}
class User
{
public string Name { get; set; }
public decimal SocialFactor { get; set; }
}
}
What the program does is insert a user node with a social factor of 0.5 into Neo4j (userIn
), and immediately retrieves the user node again (userOut
). The problem is that userOut.SocialFactor
is 5 instead of 0.5!
Strangely enough, when I change the type to double
, there is no problem, but that's obviously something I don't want to do.
Is this a bug? Is there some kind of workaround?
Thanks, Jan
Turns out that yes, it was a bug but it was recently fixed in version 1.0.0.595 of Neo4jClient.