This is a migrated thread and some comments may be shown as answers.

problem with artificial association

2 Answers 65 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
MATEUSZ
Top achievements
Rank 1
MATEUSZ asked on 19 Sep 2013, 09:18 PM
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:


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

2 Answers, 1 is accepted

Sort by
0
Accepted
Boris Georgiev
Telerik team
answered on 24 Sep 2013, 04:23 PM
Hi Mateusz,

This issue is not reproducible with the latest Telerik OpenAccess ORM official release. I would recommend you to upgrade to the latest release and verify if the problem is still reproducible - in general we do not recommend using custom builds like that once an official version has become available. 

Kindly let us know if you experience any issues with the new release.

Regards,
Boris Georgiev
Telerik
OpenAccess ORM Q3 2013 Beta is available for immediate download in your account. Get it now and play with the latest bits. See what's new >>
0
MATEUSZ
Top achievements
Rank 1
answered on 25 Sep 2013, 04:53 PM
Latest version works fine, thanks.

It's great that you made full version of OA free :)
Tags
Development (API, general questions)
Asked by
MATEUSZ
Top achievements
Rank 1
Answers by
Boris Georgiev
Telerik team
MATEUSZ
Top achievements
Rank 1
Share this question
or