데이터베이스에서 약 10 000 개의 개체를로드해야하는 경우가 있습니다.NHibernate를 사용하여 여러 레벨의 객체를 깊고 넓게 가져 오는 방법은 무엇입니까?
public class SimulationObject
{
public Container Container {get;set;}
public IList<ResultItem> Results {get;set;}
public IList<PreviewData> PreviewData {get;set;}
...
}
public class ResultItem
{
public IList<SomeDataItem> Items {get;set;}
...
}
public class PreviewData
{
public IList<SomeDataItem> Items {get;set;}
...
}
이 내가 어떤 쿼리에 따라 데이터베이스에서 SimulationObjects의 목록을 조회 할 것을 의미하고, 모든 속성 (참조)이고 하위 항목 : 데이터 모델은이 같은 것입니다.
컬렉션의 수량은 다음과 같다 :
- SimulationObject - CA 6000 - 1200 ","
- SimulationObject.Results의 파라미터에 따라 - CA 5~40 항목
- SimulationObject.Results .Items - CA 0~2 항목
- SimulationObject.PreviewData - CA 0~2 항목
- SimulationObject.PreviewData.Items - CA 1~3 항목
일반적으로, 나는 이런 식으로 할 거라고 : 그건 내 쿼리에서 데카르트 제품을 만들 것이기
var query = from sim in session.Query<SimulationObject>()
where sim.Container.Id == containerId && ...
select sim;
query = query.FetchMany(c => c.Results).ThenFetch(o => o.Items)...
그러나 나는 또한 "PreviewData"아이템을 취득 할 필요가 (의 PreviewDataAndSubItemsCount의 X의 ResultsAndSubItemsCount 금액을 의미 행이 반환 됨) 매우 효과적이지 않습니다. 또한 SumtheObjects를 많이로드해야하기 때문에 (약 10000 대 이전의 sayd) 게으른 로딩을 수행 할 수 없습니다. (10000 개의 쿼리가 있습니다. 다른 어려움도 있으므로 고려해야 할 대안이 아닙니다.)
그래서 대체 무엇입니까? 컴플 라이 트 객체 그래프를 메모리에로드하는 데 사용할 전략은 무엇입니까?
감사합니다.
10,000 개의 SimulationObject가 회사 번호입니까, 아니면 앞으로 성장할 수 있습니까? 평균적으로'SimulationObject' 당 얼마나 많은'ResultItem'이 있습니까? 'SimulationObject' 당 얼마나 많은'PreviewData'가 있습니까? 'PreviewData'와'ResultItem'에 얼마나 많은'SomeDataItem'이 있습니까? 'SomeDataItem'을 가져와야할까요, 아니면이 손자들을 게으른 로딩 할 수 있습니까? –
'SimulationObject' 내에서'PreviewData'와'ResultItem'이'SomeDataItem'을 공유합니까? 즉,'SomeDataItem x'가 주어지면,이 문장은 true가됩니다 :'x.ResultItem.SimulationObject == x.PreviewData.SimulationObject'? 그렇다면 다이아몬드 모양의 관계가 있습니다.이 관계는 손자 손 개체에 대해 수행해야 할 작업량에 영향을 미칩니다. –
아니요, 그들은 관계를 공유하지 않습니다. 사실 PreviewData 항목과 ResultItem 항목은 db의 다른 테이블에 보관됩니다. SomeDataItem 클래스는 의사 코드였습니다. 오, 그리고 게시물에 수량을 추가했습니다. – user315648