.net - How to convert to a strong type that has a collection? -
i'm trying convert entity contains collections model can't figure out how include collections in model.
for simple example of this, please see model below:
namespace models public class productmodel public property id integer public property description string public property isinstock boolean public property orders list(of productordermodel) end class public class productordermodel public property id integer public property orderdate datetime public property delivereddate datetime? public property shippingaddress string end class end namespace now can cast product model shown below:
dim simplifiedproductmodel productmodel = p in dc.products _ select new productmodel { _ .id = p.productid, _ .description = p.productdescription, _ .isinstock = p.productisinstock, _ .ordercount = p.orders.count() _ } what can't figure out how include collection using simplified model well.
dim simplifiedproductmodel productmodel = p in dc.products _ select new productmodel { _ .id = p.productid, _ .description = p.productdescription, _ .isinstock = p.productisinstock, _ .ordercount = p.orders.count(), _ .orders = p.orders.???? ===> new productordermodel { .id = ???? o.orderid , .orderdate = ???? o.createdate, etc. }
like this?
dim simplifiedproductmodel productmodel = p in dc.products _ select new productmodel { _ .id = p.productid, _ .description = p.productdescription, _ .isinstock = p.productisinstock, _ .ordercount = p.orders.count(), _ .orders = p.orders.select( _ function(o) new productordermodel _ { _ .id = o.orderid , _ .orderdate = o.createdate, _ etc. } ) }
Comments
Post a Comment