I got this entity for friendlists:
public class Friendship : IEntity
{
/// <summary>
/// Gets or sets the usr a.
/// </summary>
/// <value>
/// The usr a.
/// </value>
public virtual Users UsrA { get; set; }
/// <summary>
/// Gets or sets the usr b.
/// </summary>
/// <value>
/// The usr b.
/// </value>
public virtual Users UsrB { get; set; }
/// <summary>
/// Gets or sets the identifier.
/// </summary>
/// <value>
/// The identifier.
/// </value>
public virtual long Id { get; set; }
}
With the mapping:
public class FriendshipOverrides : IAutoMappingOverride<Friendship>
{
public void Override(AutoMapping<Friendship> mapping)
{
mapping.References(x => x.UsrA, "UsrAId").Cascade.None().Index("FriendshipUsrAIdx");
mapping.References(x => x.UsrB, "UsrBId").Cascade.None().Index("FriendshipUsrBIdx");
mapping.HasMany(x => x.Feeds).Cascade.None();
}
}
Each user can has a privacy config mapped referenced by the user entity.
So what I try is to filter out users which profile is not public.
var friendListQuery = this._FriendshipRepository.Query()!.Select(x => new
{
u = x.UsrA.Id == userId ? x.UsrB : x.UsrA,
f = x,
priv = (x.UsrA.Id == userId ? x.UsrB : x.UsrA).PrivacyConfig
})
.Where(x => x.f.UsrA.Id == userId || x.f.UsrB.Id == userId);
Everything works as expected as long I am not accessing a child entity of UsrA or UsrB (in this case PrivacyConfig).
It doesnt matter where I access it (Select, Where, OrderBy etc)
Results always in the error: Nhibernate: Cannot visit a constant without a constant to parameter map
Since the mapping of the UserObject is quiet long here a snapshot:
mapping.References(x => x.PrivacyConfig).Cascade.All();
and on privacy config override:
public class UserPrivacyDataOverrides : IAutoMappingOverride<UserPrivacyData>
{
public void Override(AutoMapping<UserPrivacyData> mapping)
{
mapping.HasOne(x => x.User).Cascade.None();
}
}
Couldnt find any solution online when searching for the error.