Adding multiple Vertical Inheritance Entities

Thread is closed for posting
2 posts, 0 answers
  1. Pedro
    Pedro avatar
    2 posts
    Member since:
    Jun 2012

    Posted 29 Jun 2012 Link to this post


    I've been struggling around with an example throwing me a strange error. Here's the scenario I'm working on:

    public abstract class A
        public Int32 Id { get; set; }
        public String Name { get; set; }
        public IList<D> Ds { get; set; }
    public class B : A
        public String Description { get; set; }
        public B()
            Ds = new List<D>();
    public class C : A
        public Int32 Value { get; set; }
        public C()
            Ds = new List<D>();
    public class D
        public Int32 Id { get; set; }
        public String Name { get; set; }
        public IList<A> As { get; set; }
        public D()
            As = new List<A>();

    Fluent Mapping
    List<MappingConfiguration> configurations = new List<MappingConfiguration>();
    MappingConfiguration<A> A = new MappingConfiguration<FluentModel1.A>();
    A.MapType(x => new
        id = x.Id,
        name = x.Name
    A.HasProperty(x => x.Id).IsIdentity(KeyGenerator.Autoinc);
    MappingConfiguration<B> B = new MappingConfiguration<FluentModel1.B>();
    B.MapType(x => new
        description = x.Description
    MappingConfiguration<C> C = new MappingConfiguration<FluentModel1.C>();
    C.MapType(x => new
        value = x.Value
    MappingConfiguration<D> D = new MappingConfiguration<FluentModel1.D>();
    D.MapType(x => new
        id = x.Id,
        name = x.Name
    D.HasProperty(x => x.Id).IsIdentity(KeyGenerator.Autoinc);
    //D.HasAssociation<A>(x => x.As).IsDependent().IsManaged().WithOpposite(x => x.Ds).MapJoinTable("AxD", (x, y) => new { IdA = x.Id, IdD = y.Id });
    //A.HasAssociation<D>(x => x.Ds).IsDependent().IsManaged().WithOpposite(x => x.As);

    (The associations have been commented out to better isolate the issue)

    Test Code:
    using (var aContext = new FluentModel1Context())
        B b1 = new B();
        //b1.Id = 99;
        b1.Name = "First";
        b1.Description = "Desc1";
        B b2 = new B();
        //b2.Id = 98;
        b2.Name = "Second";
        b2.Description = "Desc2";

    In the scenario above, the "aContext.SaveChanges()" line will throw me the following exception: "Insert of '1023727798-2' failed: Telerik.OpenAccess.RT.sql.SQLException: Previous result set was not closed."

    Further testing has shown me that the exception will not be thrown in any of the following cases:
    • If I change the A.Id identity mapping to "A.HasProperty(x => x.Id).IsIdentity();" removing the autoinc and manually handle id fields (note the commented lines on the "test code").
    • If I change the A.Id identity mapping to "A.HasProperty(x => x.Id).IsIdentity(KeyGenerator.Guid);" removing the autoinc and handling id generation with guid.
    • If I work with autoinc but in a non-inheritance entity, such as D from this example
    • If I add a "aContext.SaveChanges()" between "aContext.Add(b1)" and "aContext.Add(b2)" thus performing single operation inserts

    It seems tome the behavior is somewhere between the workings of autoinc with inheritance, but only on multiple inserts. Is it expected? Is it a bug? Is my code screwed up somehow?

    Thanks in advance.


  2. Zoran
    Zoran avatar
    534 posts

    Posted 04 Jul 2012 Link to this post

    Hi Pedro,

     We did fix a bug in our product, resulting in the same error for the Service Pack 1 of the Q2 2012 version of OpenAccess. This Service Pack was released last week. Can you confirm if you are actually using that version of our product, or you use an earlier one like the official Q2 release? If you are using an earlier version, please try updating to the latest one and test if the error is still there.

    the Telerik team
    OpenAccess ORM Q2'12 Now Available! Get your hands on all the new stuff.
Back to Top