I am unable to compile the following code from Quick Start using Visual Studio 2005:
Code:
1 IList userList = session.CreateCriteria(typeof(User)).List();
2 foreach (User currentUser in userList)
3 {
4 System.Diagnostics.Debug.WriteLine(
5 currentUser.Id + " last logged in at " + currentUser.LastLogon);
6 }
The errors I get are:
Line 1: Using the generic type 'System.Collections.Generic.IList<T>' requires '1' type arguments
Line 2: foreach statement cannot operate on variables of type '?IList?' because '?IList?' does not contain a public definition for 'GetEnumerator'
Even if try typecasting I get an InvalidCastException at runtime:
Code:
IList<User> userList = (IList<User>)(session.CreateCriteria(typeof(User)).List());
Is there a solution to this?