I want to return a list of products (DVD, CD, Blu-Ray, etc) each format has it's own internal class (for artwork sizing, processing, legality reasons, etc).
Class CD -> Implments IProduct
Class DVD -> Implements IProduct
Class BLURAY -> Implements IProduct
i.e. dim MyList = (from p in MyProductTable select p).tolist
returns 4 records.
(0)
title: Motown Unmixed
artist: Various
duration: 36:25
format: CD
upc: 024543246157
(1)
title: Classical Bytes - Bach
artist: Various
duration: 54:32
format: CD
upc: 709387901743
(2)
title: Star Wars: Episode VI - Return of the Jedi
artist: null
duration: 136.00
format: DVD
upc: 883928446172
(3)
title: Perfect Stranger
artist: null
duration: 95.36
format: BLU
upc: 043215190627
What I want is a list IPRODUCT. This could be done by hitting the database 3 times (for each format type). And appending the results into the IPRODUCT list.
I want to consolidate the 3 queries above into one query. This query would return a list of CD, DVD, and BLURAY objects.
Class CD -> Implments IProduct
Class DVD -> Implements IProduct
Class BLURAY -> Implements IProduct
i.e. dim MyList = (from p in MyProductTable select p).tolist
returns 4 records.
(0)
title: Motown Unmixed
artist: Various
duration: 36:25
format: CD
upc: 024543246157
(1)
title: Classical Bytes - Bach
artist: Various
duration: 54:32
format: CD
upc: 709387901743
(2)
title: Star Wars: Episode VI - Return of the Jedi
artist: null
duration: 136.00
format: DVD
upc: 883928446172
(3)
title: Perfect Stranger
artist: null
duration: 95.36
format: BLU
upc: 043215190627
What I want is a list IPRODUCT. This could be done by hitting the database 3 times (for each format type). And appending the results into the IPRODUCT list.
Code:
dim MyProductList as new List(of IProduct)
MyProductList.addrange((from p in MyProductTable where p.format = "CD" select new CD with {.title = p.title, etc etc etc}).tolist)
MyProductList.addrange((from p in MyProductTable where p.format = "DVD" select new DVD with {.title = p.title, etc etc etc}).tolist)
MyProductList.addrange((from p in MyProductTable where p.format = "BLU" select new BLURAY with {.title = p.title, etc etc etc}).tolist)