Hi there, You really don't need that ConvertToListOf method. Why not just use the generic version of "List" :
IList<Customer> customerList = _session.CreateSQLQuery(sqlString).List<Customer>(); If there's something weird going on with your mappings the new exception might give you a bit more info too... James On 16 March 2010 07:48, waruni <[email protected]> wrote: > hi > > i have a sql statment and it will execute using CreateSQLQuery command > i want to return the customer list using IList<Customer>; > i convert the IList into IList<T> object. > but its get following error > > "Unable to cast object of type 'System.Object[]' to type Customer" > > > Code like this : > > public IList<Customer> Execute() > { > string sqlString="Select * from Customer"; > IList list = _session.CreateSQLQuery(sqlString).List(); > IList<Customer> CustomerList= ConvertToListOf<Customer>(list); > retun CustomerList; > } > > public static IList<T> ConvertToListOf<T>(IList iList) > { > IList<T> result = new List<T>(); > foreach (T value in iList) > result.Add(value); > > return result; > } > > > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
