Get Nhibernate entity and complete it from a web service.
Posted
by Nour Sabouny
on Stack Overflow
See other posts from Stack Overflow
or by Nour Sabouny
Published on 2010-05-08T16:35:43Z
Indexed on
2010/05/08
16:38 UTC
Read the original article
Hit count: 237
nhibernate
|wcf
Hi every one. 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);
© Stack Overflow or respective owner