I got the following issue. I am trying to use the With or WithMany instruction to retrieve a linked list of roles of an business relation via an outer join. The referential integrity is in place on the database but the primary key on the roles table is a composite key. That's the reason i use an OuterJoin clause because I get an exception otherwise .
When the query gets executed the results are exactly as I expected and nicely filled with data. Nevertheless there are certain cases where there are not yet roles available in the database. So I would expect that in those cases the returned SimpleList (Roles below) would be null, cause there is not data available. Instead Simple.Data returns a SimpleLIst and if i expand the Dynamic View in debug then it says 'Empty: No further information on this object could be discovered". Even if i traverse further down and i retrieve the first object in the SimpleList, it even returns a SimpleRecord with the same information as above in debug. Only after I request a property of the SimpleRecord I get some information that the record was empty because then it returns null.
To come to the bottom line... is there anybody who can tell me how to check if a SimpleList or SimpleRecord is empty or null without traversing down the hierarchy?
I am using Simple.Data 0.16.1.0 (due to policy i can't use the beta yet)
Thanks in advance for reading the whole story...
Below is the code sample:
dynamic businessRelationRoles;
var query = db.Zakenrelaties.As("BusinessRelations")
.All()
.OuterJoin(db.Zakenrelaties_Rollen.As("Roles"), out businessRelationRoles)
.On(zr_ID: db.Zakenrelaties.zr_ID)
.With(businessRelationRoles);
foreach (var relation in query)
{
//Get the SimpleList as IEnumerable
IEnumerable<dynamic> roles = relation.Roles;
//Get the first available SimpleRecord
var role = roles.First();
//Check if any record was returned..This passes always?? Even if the SimpleList was empty
if (role != null)
{
//Get the id of the role. returns null if SimpleRecord was empty
var roleId = role.zrro_id;
}
}
Is there anybody who can help me out?