
|
If you were logged in you would be able to see more operations.
|
|
|
db4o Core
Created: 11/Jan/08 02:57 PM
Updated: 16/Jan/08 09:56 AM
|
|
| Component/s: |
Queries
|
| Affects Version/s: |
6.4.6
|
| Fix Version/s: |
7.1.26
|
|
|
Environment:
|
.NET
|
|
Issue Links:
|
Related
|
|
This issue is related to:
|
|
COR-120
SODA queries by interface and value types
|
|
|
|
|
|
|
|
| Order: |
3
|
| Iteration: |
26
|
| Original IDS Estimate: |
0 IDS
|
| Resolution Date: |
16/Jan/08 09:56 AM
|
| Labels: |
|
| Participants: |
Carl Rosenberger and Ruihua Jin
|
| Number of Attachments: |
0
|
| Number of Comments: |
0
|
|
The test program has one interface ICar:
interface ICar {}
and two implementation classes of ICar:
class Ferrari : ICar {
private string name;
public Ferrari(string n)
{
name = n;
}
}
class Bmw : ICar {
private string name;
public Bmw(string n)
{
name = n;
}
}
First of all, four objects are stored in the database:
Ferrari: name = "F430"
Ferrari: name = "F450"
Bmw: name = "Serie 5"
Bmw: name = "Serie 7"
Then the following SODA query returns different sets of objects depending on whether the interface ICar has one or more than one implementation classes:
IQuery query = db.Query();
query.Constrain(typeof(ICar));
query.Descend("name").Constrain("F450");
query.Execute();
The query returns
* all the four instances of ICar, if Ferrari and Bmw both implement ICar;
* the Ferrari object with name="F450" if only Ferrari implements ICar.
I checked out the code in QQueryBase.AddInterfaceConstraint, and found out that if I replace
constr = constr.Or(Constrain(yapClass.ClassReflector()));
with
constr = Constrain(yapClass.ClassReflector());
then I get the correct query result.
|
|
Description
|
The test program has one interface ICar:
interface ICar {}
and two implementation classes of ICar:
class Ferrari : ICar {
private string name;
public Ferrari(string n)
{
name = n;
}
}
class Bmw : ICar {
private string name;
public Bmw(string n)
{
name = n;
}
}
First of all, four objects are stored in the database:
Ferrari: name = "F430"
Ferrari: name = "F450"
Bmw: name = "Serie 5"
Bmw: name = "Serie 7"
Then the following SODA query returns different sets of objects depending on whether the interface ICar has one or more than one implementation classes:
IQuery query = db.Query();
query.Constrain(typeof(ICar));
query.Descend("name").Constrain("F450");
query.Execute();
The query returns
* all the four instances of ICar, if Ferrari and Bmw both implement ICar;
* the Ferrari object with name="F450" if only Ferrari implements ICar.
I checked out the code in QQueryBase.AddInterfaceConstraint, and found out that if I replace
constr = constr.Or(Constrain(yapClass.ClassReflector()));
with
constr = Constrain(yapClass.ClassReflector());
then I get the correct query result.
|
Show » |
| There are no comments yet on this issue.
|
|