I'm bulding a WPF application on visual studio 2013 with Entity-Framework (Code First).
I have a Order class, that has a virtual property for Customer.
public class Order
{
public int OrderId { get; set; }
public DateTime OrderDate { get; set;}
public virtual Customer Customer { get; set; }
}
public class Customer
{
public int CustomerId { get; set; }
public string Name { get; set; }
public string DocumentNumber { get; set; }
public DateTime BirthDate { get; set; }
}
I'm trying to show the customer's name on report formula. I've tried:
=First(Fields!Customer.Value.Name, "MyDataSet")
=First(Fields!Customer.Name.Value, "MyDataSet")
and
=Fields!Customer.Value.Name
=Fields!Customer.Name.Value
It just shows #Error on that field. Other fields from Order are displayed properly.
It works:
=First(Fields!OrderDate.Value, "MyDataSet")
I loaded the Customer by using Include when I retrieve the entity from context. So a null reference is not the problem.
Order order = context.Orders.Include(o => o.Customer).Where(o => o.OrderID == id).FirstOrDefault();
I searched the following and others, but sounds like is just for visual studio 2010 or just didn't work:
Bind child object property with in rdlc (Report)
http://wraithnath.blogspot.com.br/2011/04/reportviewer-object-datasource-nested.html
Is there some thing I didn't do or I should work another way on that, like some kind of "code-first-view"?