开发者

Verifying contents of NHibernate Criteria

I'm looking to build complex queries using the NHibernate Criteria API. I'd like to verify that the criteria is constructed as I would expect without having to actually run开发者_Go百科 the query.

Is this possible? Are there any tips or techniques for doing it elegantly?


A co-worker recently did this

encapsulate each criteria query in it's own class (specification). built an expression builder that will spit out the query to the string. tested that the generated expression string matches the expected expression string.

the expression builder walked the criteria tree in a specification in a recursive fashion to generate the expression string.

that's the general idea, don't have the code with me right now :) sorry.

However, I've found that it's much easier to write db integration tests to test Nh criteria. Does the criteria really return the data I expect.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜