jta wrote:
Code:
IList<AnnouncementObj> list = session.CreateCritery(typeof(AnnouncementObj).SetFetchMode("SubFirm", FetchMode.Join).List<AnnouncementObj>();
Thanks for your reply.
I used some code like this code before, but I took this error:
The value "System.Object[]" is not of type "AnnouncementObj" and cannot be used in this generic collection.
ICriteria.List<T>() turns me not the type T (AnnouncementObj in this code), but it turns a list of System.Object array that includes AnnouncementObj and SubFirmObj.
It is strange. I am missing something, I think.
edit : Oh sorry, I tried and saw that it worked for my question. Thanks a lot.
But I have a complex scenario. My code like this:
Code:
ICriteria c = session.CreateCriteria(typeof(AnnouncementObj));
//Add criteria expressions, bla bla...
c.SetProjection(Projections.Count("AnnouncementId"));
int rowCount = (int)c.List()[0];
c.SetProjection(null);
c.SetFetchMode("SubFirm", FetchMode.Join);
List<AnnouncementObj> = (List<AnnouncementObj>)c.List<AnnouncementObj>();
I need rowcount of my query for paging. If I comment this part, it works. But SetProjection (or maybe first "List") makes something wrong.
I think, I found the "strange" thing. Any ideas for this strange thing??