I have 2 views in SQL set up:
- PurchaseOrder
- PurchaseOrderLineItems
These have many columns aliased (the tables they view/join are not sensibly named... it's a 3rd party product)
I have 2 classes (simplified below)
class PurchaseOrder
{
public string PoNumber { get; set; }
public string Vendor { get; set; }
public DateTime DateCreated { get; set; }
public IEnumerable<PurchaseOrderLineItems> LineItems { get; set; }
}
and
class PurchaseOrderLineItems
{
public string PoNumber { get; set; }
public string Name { get; set; }
public double Price { get; set; }
}
I'm using Linq to Sql - with XML mapping file (created with help from sqlmetal.exe)
What I want to do is effectivly populate the IEnumerable in PurchaseOrder with records from the PurchaseOrderLineItem view - effectively joining the tables
I wanted to do this using POCO - without having to add EntitySet<> to my class, as eventually, I will change my ORM to something like nHibernate (which has bag attribute i believe...?)
Currently, I've got a stored procedure - sp_getPurchaseOrderLineItems which takes the PONumber, and then returns a list of PurchaseOrderLineItem objects, that i then add to my result set (this is far, far from ideal)
is there any way I can do what i need? So that basically, a query on PurchaseOrder returns an already populated IEnumerable of LineItems within the instance?
It's worth mentioning that this will only ever be read-only, we'll never be inserting / updating data using this.