我在检索投影中的字符串集合时遇到了一些麻烦:假设我有以下类
public class WorkSet {
public Guid Id { get; set; }
public string Title { get; set; }
public ISet<string> PartTitles { get; protected set; }
}
public class Work {
public Guid Id { get; set; }
public WorkSet WorkSet { get; set; }
//a bunch of other properties
}
然后,我有一个我想要检索 WorkSet.Title、WorkSet.PartTitles 和 Id 的工作 ID 列表。
我的强项是做这样的事情:
var works = Session.CreateCriteria<Work>()
.Add(Restrictions.In("Id", hitIds))
.CreateAlias("WorkSet", "WorkSet")
.SetProjection(
Projections.ProjectionList()
.Add(Projections.Id())
.Add(Projections.Property("WorkSet.Title"))
.Add(Projections.Property("WorkSet.PartTitles")))
.List();
Id 和 Title 加载得很好,但 PartTitles 返回 null。请提出建议!