1. You haven't told NHibernate to create Customer objects. SQL can be used to return anything. See http://nhforge.org/doc/nh/en/index.html#d0e9908 2. I suppose that "Select * from Customer" isn't the actual SQL statement? If it is, use HQL or the Criteria API instead.
/Oskar 2010/3/16 waruni <[email protected]>: > 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]. > 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.
