It’s been Long time since I used Typed Datasets, so just wanted refresh the basics differences between ‘Ordinary’ and Typed Datasets
Typed DataSet :
- A typed DataSet is a class that derives from a DataSet. As such, it inherits all the methods, events, and properties of a DataSet. Additionally, a typed DataSet provides strongly typed methods, events, and properties.
- The typed dataset is binded with the database tables(s) at design time and you have all the schema information at design time in your code. It is added as .xsd file in your application.
- This means you can access tables and columns by name, instead of using collection-based methods.
- Aside from the improved readability of the code, a typed DataSet also allows the Visual Studio .NET code editor to automatically complete lines as you type.
- Additionally, the strongly typed DataSet provides access to values as the correct type at compile time. With a strongly typed DataSet, type mismatch errors are caught when the code is compiled rather than at run time.
- Access to tables and columns in a typed dataset is also slightly faster at run time because access is determined at compile time, not through collections at run time.
UnTyped DataSet :
- Untyped dataset is an object of class System.Data.DataSet.
- It is binded with the tables at runtime.
- You are not aware of the schema of the dataset at design time. There are a variety of circumstances under which an untyped dataset is useful. The most obvious scenario is that no schema is available for the dataset. This might occur, for example, if your application is interacting with a component that returns a dataset, but you do not know in advance what its structure is. Similarly, there are times when you are working with data that does not have a static, predictable structure; in that case, it is impractical to use a typed dataset, because you would have to regenerate the typed dataset class with each change in the data structure.
- You can access the tables and columns using index no.
- More generally, there are many times when you might create a dataset dynamically without having a schema available. In that case, the dataset is simply a convenient structure in which you can keep information, as long as the data can be represented in a relational way.
- At the same time, you can take advantage of the dataset’s capabilities, such as the ability to serialize the information to pass to another process, or to write out an XML file
// This accesses the Name column in the first row of the Employee table.
string s = dsEmployee.Employee.Name;
The same call using the UnTyped Dataset as follows
string s = (string) dsEmployee.Tables[“Employee “].Rows[“Name”];
Useful References –