In my project, I use NHibernate / FluentNHibernate, and I work with two entities, contracts and services.
This is my type of contract:
[Serializable]
public partial class TTLCContract
{
public virtual long? Id { get; set; }
public virtual Iesi.Collections.Generic.ISet<TTLCService> Services { get; set; }
}
and this is my type of service:
[Serializable]
public partial class TTLCService
{
public virtual long? Id { get; set; }
public virtual Activity.Models.TTLCContract Contract { get; set; }
}
Well, as you can see, I want my contract object to have many services, and each Service should have a link to the parent Contract.
I am using FluentNhibernate. So my mapping file looks like this:
public TTLCContractMapping()
{
Table("tab_tlc_contracts");
Id(x => x.Id, "tlc_contract_id");
HasMany(x => x.Services)
.Inverse()
.Cascade.All()
.KeyColumn("tlc_contract_id")
.AsSet();
}
and
public TTLCServiceMapping()
{
Table("tab_tlc_services");
Id(x => x.Id, "tlc_service_id");
References(x => x.Contract)
.Not.Nullable()
.Column("tlc_contract_id");
}
and here is my problem: if I get a list of all contracts in db, it works. if I get a list of all services in this contract, I get a StackOverflowException ....
Do you see something wrong with what I wrote? I made a mistake?
Please let me know if you need more information.
, , ... , , , , .
, , ... !
,
,
.