Hello,
I have a "Activity" entity, this entity can have several "Task". See
the test, below, when I save the "activity", I see in NHProf two
insert. When I look
in the database the 2 records are there but the value of
"Activity" (field of "Task") is null. Of course then when I do a
GetById on "Acitvity" entity the "Tasks" property is empty.
I tried several solution in the mapping but no success.
Any idea ?
Thanks,
Entities :
-------------
public class Activity
{
public virtual int Id { get; set; }
public virtual string Code { get; set; }
public virtual string Name { get; set; }
public virtual Iesi.Collections.Generic.ISet<Task> Tasks { get;
set; }
public Activity()
{
Tasks = new Iesi.Collections.Generic.HashedSet<Task>();
}
}
public class Task
{
public virtual int Id { get; set; }
public virtual string Code { get; set; }
public virtual string Name { get; set; }
public virtual Activity Activity { get; set; }
}
The mapping :
--------------------
public ActivityMap()
{
Id(x => x.Id).GeneratedBy.Native();
Map(x => x.Code);
Map(x => x.Name);
HasMany(x => x.Tasks)
.KeyColumns.Add("Activity")
.AsSet()
.Inverse()
.Cascade.AllDeleteOrphan();
}
public TaskMap()
{
Id(x => x.Id).GeneratedBy.Native();
Map(x => x.Code);
Map(x => x.Name);
}
The Test :
--------------
activity = new Activity
{
Code = "...",
Name = "..."
};
Task task = new Task
{
Code = "...",
Name ="...",
Activity = activity
};
session.Save(activity);
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.