질문과 마찬가지로 NHinbernate를 사용하여 특정 검색어를 Fetch(Func<T,bool>)
, 심지어 FetchMany()
으로 알릴 수 있습니다. 그러나 내가 다른 방향으로하고 싶다면 어떻게해야 할까? Employee
가 자신의 프로필을 찾고 있다면nHibernate, 나는 <T>을 가져 오라고 말할 수 있지만, 내가 그것을 <T>으로 말할 수 있습니까?
예를 들어, 내가 Address
및 Salary
이 렌더링 할 것입니다 .. 우리가 클래스를 가지고 있다고
class Employee {
public virtual string Name { get; set; }
public virtual Address Address { get; set; }
public virtual double Salary { get; set; }
}
을 할 수 있습니다. 하지만 다른 직원이 찾고 있다면 어떨까요? 하나의 ASP.NET MVC 뷰를 빌드하는 것이 더 편리 할 것 같지만 숨겨져 있어야하는 데이터를 반환하지 않는 것이 좋습니다. 그래서 같은 ..
if(// myself //) {
return employee = session.Query<Employee>()
.Fetch(context => context.Address)
.Take(1)
.SingleOrDefault();
}
else
return employee = session.Query<Employee>()
.Deny(context => context.Address)
.Deny(context => context.Salary)
.Take(1)
.SingleOrDefault();
그런 다음 내보기 내가이 우주에서 가장 좋은 예가 아니다 실현하지만, 그런 일이 가능 .. 같은
@model Employee
<h2>@Model.Name</h2>
<h4>@Html.DisplayFor(model => model.Address)</h4>
<h4>@Model.Salary</h4>
을 볼 수 있는가? 지금까지는 반환하지 말라고 명시 적으로 알려주는 메소드를 찾지 못했습니다.
개 농담을위한 +1 – Martin