This question is locked. New answers and comments are not allowed.
Hello,
I've been struggling around with an example throwing me a strange error. Here's the scenario I'm working on:
Classes
Fluent Mapping
(The associations have been commented out to better isolate the issue)
Test Code:
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:
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.
Regards,
Pedro
I've been struggling around with an example throwing me a strange error. Here's the scenario I'm working on:
Classes
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
}).ToTable(
"ATable"
);
A.HasProperty(x => x.Id).IsIdentity(KeyGenerator.Autoinc);
MappingConfiguration<B> B =
new
MappingConfiguration<FluentModel1.B>();
B.MapType(x =>
new
{
description = x.Description
}).Inheritance(Telerik.OpenAccess.InheritanceStrategy.Vertical).ToTable(
"BTable"
);
MappingConfiguration<C> C =
new
MappingConfiguration<FluentModel1.C>();
C.MapType(x =>
new
{
value = x.Value
}).Inheritance(Telerik.OpenAccess.InheritanceStrategy.Vertical).ToTable(
"CTable"
);
MappingConfiguration<D> D =
new
MappingConfiguration<FluentModel1.D>();
D.MapType(x =>
new
{
id = x.Id,
name = x.Name
}).ToTable(
"DTable"
);
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);
configurations.Add(A);
configurations.Add(B);
configurations.Add(C);
configurations.Add(D);
(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"
;
aContext.Add(b1);
aContext.Add(b2);
aContext.SaveChanges();
}
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.
Regards,
Pedro