let’s say that i have an order system.
each “Order” references a “Customer” Object.
when i fill the orders list in Data Access Layer, the customer object should be brought from
a Customer Web Service “WCF”.
so i didn’t map the Customer property in the Order mapping class,
Id(o => o.OrderID).GeneratedBy.Identity();
//References(o => o.Customer).Not.Nullable().Column("CustomerID");
HasMany(o => o.Details).KeyColumn("OrderID").Cascade.AllDeleteOrphan();
Map(c => c.CustomerID).Not.Nullable();
and asked the nhibernate session to get me the orders list.
and tried to loop on every order in the list to fill it’s customer property,
doe’s any body have a good idea for this ????
IList<Order> lst = Session.CreateCriteria<Order>().List<Order>();
foreach (Order order in lst)
order.Customer = serviceProxy.GetCustomerByID(order.CustomerID);
So you’re saying that you hit your WCF, for Order list of 50, 50 times. Not so good.
You should do this:
That is for performance vise.
The other thing that you can do and be fancy (and not so performace oriented, but exactly the same performace as your sample):
modify property Customer as this:
Where your order should have a reference to serviceProxy.