return _session.CreateSQLQuery("select * from Customer")
.AddEntity(typeof(Customer))
.List<Customer>();
You don't need to manually convert the values, but you DO need to specify
the entities you're retrieving when using SQL Queries.
This is in the docs, http://nhforge.org/doc/nh/en/index.html#d0e9908
Diego
On Tue, Mar 16, 2010 at 04: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.