This question is locked. New answers and comments are not allowed.
Hello, I have a problem with using artificial association.
Unfortunatelly, I use Telerik-OpenAccess-ORM-2012.2.924.1, but I hope it's not the main problem...
Some code at first:
So, I have two classes called Role and Fake. They are mapped and extended with some artificial association. The main purpose of that is to be able to assign instance of Fake to and instance of Role. And here the problem starts:
Unfortunately, this piece of code causes ArgumentOutOfRangeException:
No such persistent field known.
Parameter name: nameOfPersistentField
Actual value was Fake.
which comes from Telerik.OpenAccess.ExtensionMethods.GetPropertyDescriptor(Object persistentInstance, String nameOfPersistentField)
Can you see any flaw in my code? Or mayby this is a known issue?
Thanks...
Unfortunatelly, I use Telerik-OpenAccess-ORM-2012.2.924.1, but I hope it's not the main problem...
Some code at first:
public class Role : EntityBase, IEntityWithKey<
int
>, INameable
{
public int Id { get; set; }
public string Name { get; set; }
private TrackedBindingList<
RoleItem
> roleItems = new TrackedBindingList<
RoleItem
>();
public IList<
RoleItem
> RoleItems
{
get { return roleItems; }
}
}
public class Fake : EntityBase, IEntityWithKey<
int
>, INameable
{
public int Id { get; set; }
public string Name { get; set; }
}
var roleMapping = new MappingConfiguration<
Role
>();
roleMapping.MapType(u => new
{
u.Id,
u.Name,
}).ToTable("Roles");
roleMapping.HasProperty(u => u.Id).IsIdentity(KeyGenerator.Autoinc);
var fakeMapping = new MappingConfiguration<
Fake
>();
fakeMapping.MapType(u => new
{
u.Id,
u.Name
}).ToTable("Fakes");
fakeMapping.HasProperty(u => u.Id).IsIdentity(KeyGenerator.Autoinc);
fakeMapping.HasArtificialCollectionAssociation("Roles", typeof(Role))
.WithOpposite("Fake");
roleMapping.HasArtificialAssociation("Fake", typeof(Fake))
.WithOppositeCollection("Roles")
.ToColumn("FakeId");
So, I have two classes called Role and Fake. They are mapped and extended with some artificial association. The main purpose of that is to be able to assign instance of Fake to and instance of Role. And here the problem starts:
var role = new Role();
var fake = new Fake();
ctx.Add(role);
ctx.Add(fake);
role.SetFieldValue("Fake", fake);
Unfortunately, this piece of code causes ArgumentOutOfRangeException:
No such persistent field known.
Parameter name: nameOfPersistentField
Actual value was Fake.
which comes from Telerik.OpenAccess.ExtensionMethods.GetPropertyDescriptor(Object persistentInstance, String nameOfPersistentField)
Can you see any flaw in my code? Or mayby this is a known issue?
Thanks...