Vb.net 2010 Reading sub properties of an object in reportViewer
I am creating some reports using object datasources.
I have the following scenario:
in my software the user can create a list of products specifying a code, the product name, the price and the vat rate (this last two attributes will be used as suggestions when the user will place the product inside an order).
When a user creates an order he can place products within it by specifying for each product the quantity and he can also override the suggested price and the vat rate.
So basically i have two models to represent the products:
- ProductModel (used to define product name, product code and the default suggestion for price and vat rate)
- OrderProductModel (used to place products within an order, specify the quantity and override the default product suggestion for price and vat number)
ProductModel:
- id
- code
- name
- price
- vat
OrderProductModel:
- id
- order (reference to an OrderModel object)
- product (reference to a ProductModel to read the code and the name and the suggestions for price and vat rate)
- quantity
- price
- vat
Now what I need to do with my report is to fill a table of OrderProduct objects and show the following informations fo开发者_StackOverflow社区r each product:
- code (orderProduct.product.code)
- name (orderProduct.product.name)
- price (orderProduct.price)
- quantity (orderProduct.quantity)
(suppose orderProduct is an instance of OrderProductModel)
Now the question is "how to define the report rule to access to code and name?"...
I am using visual studio 2010 and by reading here: http://www.gotreportviewer.com/objectdatasources/index.html
they says that the syntax: =Fields!Object.Value.attribute
no longer works...
I tought i could solve the problem by adding to the OrderProductModel some properties that will read the properties of the related ProductModel instance. But i'm sure there are better way that does not break the model...
Just an update to this, its now fixed in SP1. The requirement to get it to work is to make sure ALL classes used in properties of the datasource are serializable.
more info at:
http://wraithnath.blogspot.com/2011/04/reportviewer-object-datasource-nested.html
I found that this is a bug... if you make all your object serializable this should be fixed in the SP1 ...
read more here: http://blogs.msdn.com/b/brianhartman/archive/2010/10/27/nested-objects-in-local-mode.aspx
精彩评论