我有一個查詢得到Child
對象的一個Parent
對象。
我需要將結果轉換爲List<KeyValuePair<int, int>>
無法弄清楚。nhibernate投影到匿名類型
Child childAlias = null;
Parent parentAlias = null;
int[] parentIds = new int[]{1,2,3};
var temp = sess.QueryOver<Parent>()
.JoinQueryOver(p => p.Children,() => childAlias)
.Where(c => c.Parent.Id.IsIn(parentIds))
.Select(Projections.ProjectionList()
.Add(Projections.GroupProperty(Projections.Property<Parent>(x => x.Id)))
.Add(Projections.Count(() => childAlias.Id)))
.List<object[]>();
我需要這個List<object[]>
是一個List<KeyValuePair<int, int>>
我知道它涉及與annonymous對象Select
,但無法弄清楚
當你調試它,什麼是在'temp'項目的實際類型? –
用'List'聲明瞭它的一個對象數組的列表,沒有'List'它的一個'IQueryOver' –
heyNow