【发布时间】:2013-09-13 12:13:44
【问题描述】:
这是我的简单 С# 代码:
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;
}
}
在foreach 循环中,NHibernate 将 SQL 查询发送到我的数据库。为什么?关于GameCharacterEquipment 的信息已在内部连接的第一个查询中请求。
我有流利的地图。
【问题讨论】:
-
请添加一些领域模型类和映射。这将导致更好的答案,因为可以猜测的更少。
标签: c# sql nhibernate fluent-nhibernate