Following the guidance from Designing Data Tier Components and Passing Data Through Tiers http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/BOAG
ag.asp?frame=true, I don’t understand how to divide my database tables into typed datasets
The guide recommends to make the dataset a little more abstract than the database schema, joining many-to-many relations in one of the datasets, and so forth
This creates a problem when I want to use a relation between 2 datasets(a relation between 2 tables in 2 datasets.)
If we take the example from the guide The create a Order DataSet(Order and OrderDetails) and Products DataSet(Products). In the database there is actually a relation between OrderDetails and Product. How do I implement this relation??? Without using generic a dataset??
I'm not exactly sure what you're asking in your question,
but I suspect you want to know how to create a relation in
a non SQL Server database (such as Oracle). There are a
couple of possibilities. One is create Primary and Foreign
keys - thus creating a join is easy. A second is to create
a view. The second is my preferred option, as frequently I
want to relate things in terms that have nothing to do
with the primary and foreign keys. You can create views in
SQL server as well. Have a look at the microsoft help on
JOIN and VIEW if you need help on using those.
Looking again at your question, you ask how to create a
dataset containing the order details about a related
product. This is easy - you set up the usual connection
and command objects, and create the dataset based on a SQL
statement like "SELECT ORDERS.ORDERDATE,
ORDERDETAILS.QUANTITY, PRODUCTS.PRODUCTNAME FROM ORDERS,
ORDERDETAILS, PRODUCTS WHERE ORDERS.ORDERID =
ORDERDETAILS.ORDERID AND ORDERDETAILS.PRODUCTID =
PRODUCTS.PRODUCTID". If you creat a view (called
VW_ORDER_DETAILS_PRODUCTS), it could use exactly the same
SQL as above.
I hope I am answering the question you want answered.
Paul.
Morten Lyhr - 29 Apr 2004 07:36 GMT
Obviously, I did not make my self very clear
Database schema
Produc
Orde
OrderDetail
Stored Procedures
GetProduct
GetProductsByI
GetOrder
GetOrderByI
GetOrderDetail
GetOrderDetailsByI
….and so fort
Typed DataSets
OrderDataSe
Orde
OrderDetail
ProductDataSe
Produc
Data Access Logic Component
Orde
Produc
When the Business Process Components or GUI uses the DALC/BE(DataSet), it works fine when its just work within 1 BE(DataSet)
BE.OrderDataSet orderDataSet = new DALC.Order().GetOrderById(2)
//BE. orderDataSet is typed
DataTime dt = orderDataSet.order[0].OrderData
So thats all nifty…
But what should I do, if I need more that 1 DataSet
I have a control that needs a DataSet for binding, and It shows a Order, with details about each product
• I could make an “all” DataSet with all my tables in it
• I could use merge and a DaaView (and loose my typed ability???
• Create a method in the DALC getting all Products for an Orde
I think the Guide recommends the last one (page 8, Recommendations for Mapping Relational Data to BE, 2nd section)
So my Q is: Can anyone make an example of how these DALC methods look like, and how do I use them without loosing the typed ability