开发者

NHiberate 3 and QueryOver

开发者 https://www.devze.com 2023-01-20 17:23 出处:网络
I\'ve got an issue trying to code up some Q开发者_如何学PythonueryOver query. I\'ve got an entity Branch, which has a list of Users entities - UserList. I\'ve coded the QueryOver object, I\'ve got the

I've got an issue trying to code up some Q开发者_如何学PythonueryOver query. I've got an entity Branch, which has a list of Users entities - UserList. I've coded the QueryOver object, I've got the join right using an alias, BUT ( see code )

Iesi.Collections.Generic.ISet<User> userAlias = null;
IQueryOver<Branch, Iesi.Collections.Generic.ISet<User>> userQuery = branchQuery.JoinQueryOver( branch => branch.UserList , () =:> userAlias ) ;
ProjectionList projections = Projections.ProjectionList().Add(Projections.Sum<Iesi.Collections.Generic.ISet<User>>( user => user.CreditLimit));

what I now have a problem with is the last line, being the projection. The alias is typed as an ISet, which means it has no properties, IE the code I have there will not compile because and object of Type User has a CreditLimit property but an object of Type ISet, has properties like count and Add/Remove methods. If I change the alias to a type of User and not ISet, well that's just not going to work because I'm working with a set not an entity.

Does anyone have any ideas on how can I code this. This is a very simplified query so starting off with the User entity and joining to Company would work in the above code, but not in my real life scenario where I've got two joining entities.

0

精彩评论

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