1
QueryOver를 시도하고 비공개 속성을 반환하는 속성을 선택하려고합니다. 나는 그것을 잘 설명 할 수는 없지만 그 예가 당신에게 말할 것입니다.NHibernate QueryOver 속성을 확인할 수 없습니다.
매핑 :
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="IWA.Model" assembly="IWA.Model">
<class name="Test" lazy="false" table="Test">
<id name="Id" column="Id" >
<generator class="identity" />
</id>
<bag name="_images" access="field" table="Image" cascade="none">
<key column="IdTest" />
<one-to-many class="Image" />
</bag>
</class>
</hibernate-mapping>
등급 :
public class Test : IEntity<int>
{
private readonly IList<Image> _images;
public Test()
{
_images = new List<Image>();
}
public int Id { get; set; }
public Image Image => _images.FirstOrDefault();
}
QueryOver :
TestDto r = null;
Session.QueryOver<Test>()
.Where(x => x.Id == _id)
.Select(
Projections.Property<Test>(x => x.Id).WithAlias(() => r.Id),
Projections.Property<Test>(x => x.Image).WithAlias(() => r.Image)
) .TransformUsing(Transformers.AliasToBean<TestDto>())
.SingleOrDefault<TestDto>();
내가이 쿼리를 시도 할 때 내가 할 '공동 uld가 속성을 해석하지 않습니다 '. 예상치 않은 쿼리가 정상적으로 작동합니다.
내가 뭘 잘못하고 있니?
'Projections.SqlProjection'을 사용해 보셨나요? – Najera
@Najera 아니, 전에 들어 본 적이 없어. –