これが私の単純な С# コードです。
var chests = _session.CreateCriteria<GameCharacterChest>()
.CreateAlias("GameCharacterEquipments", "equip", JoinType.InnerJoin)
.Add(Restrictions.Eq("GameCharacterId", characterId))
.List<GameCharacterChest>();
foreach (var chest in chests)
{
var equip = chest.GameCharacterEquipments.FirstOrNull();
if (equip != null)
{
var slot = (equip as GameCharacterEquipment).GameCharacterSlotTypeId;
}
}
サイクルでNHibernateはforeach
SQLクエリをDBに送信します。なんで?GameCharacterEquipment
内部結合による最初のクエリで既に要求されている情報。私は流暢な地図を持っています。