This is a discussion on Invalid cast from base to derived - CSharp ; Hi, "INeedADip" <ineedadip@gmail.com> wrote in message news:1190061774.374186.163110@d55g2000hsg.googlegroups.com... > Thanks for helping me here. > > Order, OrderItem, AdditionalCharge, and other objects of this nature > are 1 to 1 mappings to tables in a database that I can't really > ...
Hi,
"INeedADip" <ineedadip@gmail.com> wrote in message
news:1190061774.374186.163110@d55g2000hsg.googlegroups.com...
> Thanks for helping me here.
>
> Order, OrderItem, AdditionalCharge, and other objects of this nature
> are 1 to 1 mappings to tables in a database that I can't really
> change.
Ok, that is fine.
Instead of passing around and order and a collection of
> OrderItem and AdditionCharge (etc...) I figured I would create an
> object that encompasses all of them called OrderDetails.
There is the error, an Order is not an OrderDetail, why you want to treat
them in the same way?
For example an OrderDetail cannot exist outside an Order.
> DAL.GetOrder does return an object of type "Order" but on that line I
> get:
>
> "Unable to cast object of type 'Order' to type 'OrderDetails'"
Cause they are sibling, you cannot cast one into the other.