views:

131

answers:

0

I have an hql query

 string hql = @"select distinct ba, bp from BstArea as ba, BstPhoneInfo as bp
                        where bp.CodeSegment like :mobilePhoneNumber 
                        and ba.AreaCode =  bp.AreaCode";

Now, I want to create a query to execute this hql and retrieve the result. I tried

 SimpleQuery q = new SimpleQuery(typeof(BstArea), hql);
 q.SetParameter("mobilePhoneNumber", mobilePhoneNumber + "%");
 return ActiveRecordMediator.ExecuteQuery(q);

But it didn't work. The error message I got was

System.InvalidCastException : At least one element in the source array could not be cast down to the destination array type.

Sure, the BstPhoneInfo is not of type BstArea. So, the "new SimpleQuery(typeof(BstArea)" is the problem. But I couldn't find a way to set more than one types to the SimpleQuery constructor. So, what should I do here to get both of the objects?