After reading the Designing Data Tier Components and Passing Data Through Tiers whitepaper by Microsoft, I wanted to start using strongly typed datasets for my business entities.
This presents one small problem, the Compact Framework doesn't support strongly typed datasets in the IDE. But with a little hacking here, and a little hacking there, and a lot of code deletion you too can have strongly typed datasets in the Compact Framework.
Here are the basic steps to help you find your way. I plan to write an in depth article with screen captures sometime in the near future:
- Create a new Visual Studio .NET 2003 solution.
- Add a new C# Desktop Windows Application.
- I name it DTSNorthwindDesktop.
- Add a new C# Smart Device Application, as Pocket PC, Windows Application.
- I name it DTSNorthwindMobile.
- In DTSNorthwindDesktop, add a SQLDataAdapter to the form.
- Run the Data Adapter Configuration Wizard.
- Create a connection to your SQL database.
- I connected to the Northwind database.
- I used the following SQL command: "SELECT CustomerID, CompanyName FROM Customers"
- Run the Generate Dataset Wizard.
- I name the strongly typed dataset: tdsCustomers.
- Click on the DTSNorthwindDesktop, click on the Show All Files button in the solution explorer.
- You should now be able to see the tdsCustomers.cs under the tdsCustomers.xsd file.
- Copy the tdsCustomers.cs and the tdsCustomers.xsd to the DTSNorthwindMobile project.
- Add the existing items tdsCustomers.cs and the tdsCustomers.xsd to the DTSNorthwindMobile project.
- You can now attempt to build the solution.
- You will have numerous build errors that can usually be corrected by deleted the offending lines of code.
- You will probably want to rename the tdsCustomers.cs file's namespace from DTSNorthwindDesktop to DTSNorthwindMobile.
- From here you just write the standard strongly typed dataset code and you're good to go!
The full article will follow based on free time and demand.
I'm betting strongly typed datasets are fully supported in Whidbey.