| ADO NET 2 0 Object Mapper - Multi-table queries |
| Mike MacDonald posted at Tuesday, July 04, 2006 8:07 PM |
After reading the Readme file and the .NET 2.0 generics article, I'm still a tad confused when it comes to using the generated classes for stored procedures that have multiple table queries. I'm hoping that someone will be able to clarify.
Let's say, for example, a database has two tables - TableA and TableB and a stored procedure - ProcX, which uses both tables in a select query.
The ADO.NET Object Mapper will generate the data classes (TableA.cs, TableB.cs) and associated interfaces (ITableA.cs, ITableB.cs) for the tables. These can be placed into an assembly named DataTransfer. The mapper will also generate a class for the stored procedure (ProcX.cs) and a wrapper for the stored procedure (also named ProcX.cs), both of which can be placed into an assembly named Database. The Database assembly references the DataTransfer assembly as well as another assembly named BusinessRules (which also references the DataTransfer assembly).
In the BusinessRules assembly, I create a new class named Result. If ProcX only queried from TableA, then this Result class would inherit DataTransfer.Tables.TableA and the user interface layer could then use the Result class when retrieving a generic list or DataTable. However, ProcX queries from both TableA and TableB and the Result class can’t inherit both.
So, what must I do in the Result class to make it work with ProcX and properly use the TableA and TableB classes (let’s say the query is selecting ColA1, ColA2, ColA3 from TableA and ColB6, ColB7 from TableB where TableB.ColB2 = TableA.ColA1)? |
 |
|
|
| |