Fluent NHibernate HasMany 콜렉션을 설정하는 데 문제가 있습니다.Fluent NHibernate HasMany 콜렉션이 채워지지 않음
다음과 같이 코드를 설정하고 Linq IQueryable을 통해 호출합니다. SQL 프로파일 러에서 올바른 SQL이 호출 된 것을 볼 수 있지만 Store.Staff 컬렉션은 항상 비어 있습니다.
public class Store
{
public virtual IList<Employee> Staff { get; set; }
public virtual void AddEmployee(Employee Employee)
{
Employee.Store = this;
if(Staff == null)
Staff = new List<Employee>();
Staff.Add(Employee);
}
public class StoreMap : ClassMap<Store>
{
public StoreMap()
{
Id(x => x.StoreId)
.GeneratedBy.Identity();
HasMany(x => x.Staff)
.Inverse()
.Cascade.All();
...
}
}
public bool Create(Store entity)
{
var stores = _readRepository.Query<Store>()
.Where(x => x.StoreId == entity.StoreId)
.Fetch(x => x.Staff)
.ToList();
select store0_.StoreId,
staff2_.SurgeryId,
staff2_.StoreId
from dbo.[Store] store0_
left outer join dbo.[Employee] staff2_
on store0_.StoreId = staff2_.StoreId
where store0_.StoreId = 1 /* @p0 */
어떤 도움을 주셔서 감사합니다.