Skip to content

Error while retrieving Inherited entity #2

Closed
sonyarouje opened this Issue May 24, 2012 · 1 comment

1 participant

@sonyarouje
Owner

Issue is reported by Hooman through blog post http://sonyarouje.com/2012/02/03/neo4jd-net-client-for-neo4j-graph-db/#comment-6692

Issue Description

hi. sorry my engllish is not very good. this kind of db was always in my dream. and i want to thank u for this very nice api(neo4jd).

i have one question. here is my model :

public abstract class Person

{

[EntityId]

public int Id{get;set;}

}

public class Employee : Person

{

public string Name {get;set;}

}

public class Manager : Person

{

public string OfficeName{get;set;}

}

public class MyClass

{

[EntityId]

public int Id{get;set;}

public Person SelectedPerson{get;set;}

}

i’ve created map class for all.

here is the map class of MyClass:

public class MyClassMap : EntityConfiguration

{

public MyClassMap()

{

RelatedTo(p => p.SelectedPerson);

}

}

my question is when i create instance from MyClassMap and persist in the neo4j every thing is ok. but when i want to get this object from neo4j i get this error

Retrieved object with ID ’1′ is an instance of ‘Domain.Entity.Manager’ and unable to cast it to ‘Domain.Entity.Person’

what should i do?

thank you.
Hooman

@sonyarouje
Owner

The issue is fixed. The issue fix requires some reflection mechanism, so added a new function to ModelBuilder called AddAssembly(). The user should add all the assemblies that has classes that needs to be persisted in Neo4j using ModelBuilder.AddAssembly().

How to add Assembly, simple
ModelBuilder.AddAssembly(@"C:\GitRepo\Neo4jD\Test.Neo4jclient.dll");
That means AddAssembly is looking for a full path to the assembly with assembly name.

If the entities are not inherited then you can skip adding assemblies to ModelBuilder.

@sonyarouje sonyarouje closed this May 24, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.