Problem with 0:n relationship

Nov 16, 2009 at 12:52 PM

Hi,

I try to implement an 0:n relationship and I have a problem in some cases where the child relation haven't records.

I have 2 classes : Person and User and a Person entity can have a 0 or more User entity accounts.

The classes lookes like:

[TypeStorage(TableName = "person")]

public class PersonEntity : Entity

{

<font size="2">

[

</font>

FieldStorage(IsKey = true, IsIdentity = true, IdGeneratorLocation = IdentityGenerationLocation.Repository)]

public int personID;

[FieldStorage]

public string name;

[FieldStorage]

public string surname;

[FieldStorage]public int unitID;

[ChildStorage(ChildType = typeof(UserEntity), AllowNull = true, IsReference = true)]

[ForeignKey(ParentFieldName = "personID", ChildFieldName = "personID")]

public ChildCollection <UserEntity> UserCollection;

....

 

 

The user class looks like above:

<font size="2">

[

</font>

TypeStorage(TableName = "user")]

public class UserEntity : Entity

{

<font size="2">

 

</font>

[FieldStorage(IsKey = true, IsIdentity = true, IdGeneratorLocation = IdentityGenerationLocation.Repository)]

public int userID;

[FieldStorage]

public int personID;

[FieldStorage]

public string password = string.Empty;

[FieldStorage]

public string username = string.Empty;

......

public int unitID;

public static Criteria ByUserName(string username){

return new Expression(typeof(UtilizatorEntity), UtilizatorEntity.GetField(typeof(UtilizatorEntity), "username"), CriteriaOperator.Equal, username);

}

....

 

Into a grid I want to display the informations about all Person entities from a given unitID.

In some cases everything goes okay, for a unitID the persons are showed (if the person have 1 or more accounts),  but when the person haven't accounts into User Entity this person isn't showed and the error cachted into the output window is "A first chance exception of type 'Retina.RetinaCriticalException' occurred in Retina.Core.dll"

Into Exception object from the try catch statement is "Unexpected critical exception occurred. Please check the inner exception for more details" and into events log from my Windows OS

1) Exception Information

*********************************************

Exception Type: System.NullReferenceException

Message: Object reference not set to an instance of an object.

Data: System.Collections.ListDictionaryInternal

TargetSite: Void SetValue(Retina.Entity, System.Object)

HelpLink: NULL

Source: Retina.Core

StackTrace Information

*********************************************

at Retina.EntityMember.SetValue(Entity entity, Object dataValue)

at Retina.EntityStorageDefn.PopulateEntity(IDataReader reader, Entity entity, ITxnContext txnContext, Boolean readPrimaryKey, Int32 maxDepth, Int32 currentDepth, IdentityMap identityMap, Boolean fetchSingleRow)

at Retina.BaseEntityPersister.RetrieveMatches[T](ITxnContext txnContext, Object appContext, Criteria criteria, Int32 maxDepth, Int32 currentDepth)

at Retina.DataStoreBrokers.InternalDataStoreBroker.RetrieveMatches[T](ITxnContext txnContext, Object appContext, Criteria criteria, Int32 maxDepth)

at Retina.DataStoreBrokers.Enterprise.Reader.RetrieveMatches[T](ITxnContext txnContext, Object appContext, Criteria criteria, Int32 maxDepth)

at Retina.DataStoreBrokers.Enterprise.TxnContext.RetrieveMatches[T](Object appContext, Criteria criteria, Int32 maxDepth)

at Retina.DataStoreBrokers.Enterprise.DataStoreBroker.RetrieveMatches[T](Criteria criteria)

 

Assembly version: 2.0.0.0

RuntimeVersion: v2.0.50727

Compilation: RELEASE

Assembly file version: 2.0.020924.0

 

 

PLEASE HELP ME :).

DANIEL.