In this case what you want is HqlBasedQuery Your query will be a projection, so what you'll get back will be an ArrayList of tuples containing the results (the content of each element of the ArrayList will depend on the query, but for more than one value will be object ).
In this case what you want is HqlBasedQuery. Your query will be a projection, so what you'll get back will be an ArrayList of tuples containing the results (the content of each element of the ArrayList will depend on the query, but for more than one value will be object). HqlBasedQuery query = new HqlBasedQuery(typeof(WorkStationEvent), "select count(1) as cnt, data from workstationevent where serverdatetime >= :minDate and serverdatetime :threshold"); var results = (ArrayList)ActiveRecordMediator.
ExecuteQuery(query); foreach(object tuple in results) { int count = (int)tuple0; // = cnt string data = (string)tuple1; // = data (assuming this is a string) // do something here with these results } You can create an anonymous type to hold the results in a more meaningful fashion. For example: var results = from summary in (ArrayList)ActiveRecordMediator. ExecuteQuery(query) select new { Count = (int)summary0, Data = (string)summary1 }; Now results will contain a collection of anonymous types with properties Count and Data.
Or indeed you could create your own summary type and populate it out this way too. ActiveRecord also has the ProjectionQuery which does much the same thing but can only return actual mapped properties rather than aggregates or functions as you can with HQL.
Thanks! I will try that out tonight! – Slav Dec 12 '08 at 9:54 I've seen Ayende do something like this.
I'll also have to give it a try. – rball Mar 25 '09 at 15:43.
Be aware though, if you're using ActiveRecord 1.0.3 (RC3) as I was, this will result in a runtime InvalidCastException. ActiveRecordMediator. ExecuteQuery returns an ArrayList and not a generic ICollection.So in order to make it work, just change this line: var results = (ICollection) ActiveRecordMediator.
ExecuteQuery(query); to var results = (ArrayList) ActiveRecordMediator. ExecuteQuery(query); and it should work. Also note that using count(1) in your hql statement will make the query return an ArrayList of String instead of an ArrayList of object (which is what you get when using count(*).
) Just thought I'd point this out for the sake of having it all documented in one place.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.