开发者

help translating linq query to nhibernate

I'm trying to learn nhibernate but I'm finding a big learning curve. I've tried creating a linq to nhibernate query but it doesn't seem to be supported so I've decided to try and use QueryOver. I'm trying to translate this

            results = (from purchase in _session.Query<Purchase>()
                       group purchase by purchase.symbol into purchases
                       select new Quote
                       {
                           shares = purchases.Sum(p => p.shares)
                       }).ToList();

but so far all I got is this

        var results2 = _session.QueryOver<Purchase>()
            .SelectList(list => list
                .SelectGroup(g => g.symbol)
                .SelectSum(g => g.shares)).List();

and it doesn't even work. Can someone point me in the 开发者_开发问答right direction please?

Thanks


All you've done is translate a LINQ query into the equivalent utilizing extension methods. Functionality, there is no difference between the two, since the from..select syntax is just translated by the compiler. What errors are you getting and what version of NHibernate are you using?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜