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 nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
/Oskar
2010/3/16 waruni <war...@gmail.com>:
I followed the above query but i gor following error
"The value "System.Object[]" is not of type "Customer" and cannot be
used in this generic collection.
Parameter name: value"
waruni
> > nhusers+u...@googlegroups.com<nhusers%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.- Hide quoted text -
>
> - Show quoted text -
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.