Back to: ADO.NET Core Tutorial For Beginners and Professionals
ADO.NET Core DataSet with Examples
In this article, I will discuss ADO.NET Core DataSet with Examples. Please read our previous article discussing ADO.NET Core DataTable. At the end of this article, you will understand the following pointers:
- What is ADO.NET Core DataSet?
- Example to understand ADO.NET Core DataSet
- ADO.NET Core DataSet using SQL Server
- Copy, Clone, and Clear Methods of DataSet in ADO.NET Core
- How Do We Remove a DataTable from ADO.NET Core DataSet?
- Batch Insert, Update, and Delete using DataSet
- When to Use ADO.NET Core DataSet?
ADO.NET Core DataSet
The ADO.NET Core DataSet is a collection of data tables containing relational data in memory in tabular format. The ADO.NET Core DataSet is designed for data access in the .NET Core Framework. It is a disconnected, in-memory representation of data that can work with multiple data sources, making it suitable for developing applications that interact with databases. Here’s a detailed overview of what the ADO.NET Core DataSet is and its key features:
Key Characteristics
- Disconnected Data Architecture: Unlike direct connections to a database that remain open until the operation completes, a DataSet operates independently of the data source. This means it can hold data fetched from a database, and the connection to the database can be closed. The DataSet allows you to work with the data in memory, reducing the need for persistent database connections and improving application performance and scalability.
- In-Memory Cache of Data: The DataSet contains a collection of DataTable objects you can think of as in-memory representations of database tables. These tables can contain rows, columns, and constraints like a database schema. Additionally, DataRelation objects can be used within a DataSet to define relationships between tables, similar to foreign key relationships in a database.
- Independent of Data Source: One of the key benefits of the DataSet is its ability to work with data from various sources. While commonly used with relational databases through the DataAdapter component, it can also handle data from XML sources or application-generated data, providing a unified approach to handling data within .NET applications.
Components
- DataTable: Represents one table of in-memory data with rows and columns.
- DataColumn: Defines the schema of a column in a DataTable, including the column’s data type, name, and other constraints.
- DataRow: Represents a single row in a DataTable.
- DataView: Provides a customizable view of a DataTable for sorting, filtering, searching, and editing.
- DataRelation: Defines relationships between DataTable objects, similar to foreign key relationships in databases.
Usage
The DataSet is useful in applications that require manipulation and presentation of complex data structures, batch updates, and operations that require an in-memory representation of data from multiple tables with relations. It’s widely used in Windows Forms and ASP.NET applications for data binding.
Example to understand ADO.NET Core DataSet:
Let us understand how to create and use ADO.NET Core DataSet with an example. Here, we want to create two data tables (Customers and Orders), and then we want to add both these data tables to the DataSet, and then we want fetch and display data into the Console window. The following example code is self-explained, so please go through the comment lines for a better understanding.
using System.Data; namespace ADODOTNETCoreDemo { class Program { static void Main(string[] args) { try { //Call the methods to create the DataSet and display its data DataSet dataSet = CreateDataSet(); DisplayData(dataSet); } catch (Exception ex) { Console.WriteLine($"Exception Occurred: {ex.Message}"); } } //The CreateCustomersTable method create a DataTable for customers static DataTable CreateCustomersTable() { DataTable table = new DataTable("Customers"); table.Columns.Add("CustomerId", typeof(int)); table.Columns.Add("Name", typeof(string)); table.Columns.Add("Email", typeof(string)); table.Rows.Add(1, "John Doe", "john.doe@example.com"); table.Rows.Add(2, "Jane Smith", "jane.smith@example.com"); return table; } //The CreateOrdersTable method create a DataTable for orders static DataTable CreateOrdersTable() { DataTable table = new DataTable("Orders"); table.Columns.Add("OrderId", typeof(int)); table.Columns.Add("CustomerId", typeof(int)); table.Columns.Add("OrderDate", typeof(DateTime)); table.Rows.Add(1, 1, DateTime.Now); table.Rows.Add(2, 2, DateTime.Now.AddDays(-1)); return table; } //Add DataTables to DataSet //The following CreateDataSet method add DataTable instances to a DataSet: static DataSet CreateDataSet() { DataSet dataSet = new DataSet(); dataSet.Tables.Add(CreateCustomersTable()); dataSet.Tables.Add(CreateOrdersTable()); return dataSet; } //Fetching Data from the DataSet //The following method fetch and display the data from the dataset static void DisplayData(DataSet dataSet) { Console.WriteLine("Customers:"); foreach (DataRow row in dataSet.Tables["Customers"].Rows) { Console.WriteLine($"ID: {row["CustomerId"]}, Name: {row["Name"]}, Email: {row["Email"]}"); } Console.WriteLine("\nOrders:"); foreach (DataRow row in dataSet.Tables["Orders"].Rows) { Console.WriteLine($"Order ID: {row["OrderId"]}, Customer ID: {row["CustomerId"]}, Order Date: {row["OrderDate"]}"); } } } }
This application creates in-memory tables for customers and orders, adds them to a DataSet, and fetches the data to display in the console. This approach is useful for scenarios where you want to work with data programmatically without setting up a database. When you run the above code, you will get the following output:
ADO.NET Core DataSet using SQL Server
Let us see how we can fetch the data from the database, fill the dataset, and then use the dataset in memory. First, connect to your SQL Server instance, create a new database, and then create Customers and Orders tables. You can use SQL Server Management Studio (SSMS), Azure Data Studio, or any preferred SQL client tool. So, please execute the following code:
-- Create a new database (skip if you already have a database) CREATE DATABASE OrderDB; GO -- Use your database USE OrderDB; GO -- Create Customers table CREATE TABLE Customers ( CustomerId INT PRIMARY KEY, Name NVARCHAR(100), Email NVARCHAR(100) ); GO -- Create Orders table CREATE TABLE Orders ( OrderId INT PRIMARY KEY, CustomerId INT, OrderDate DATETIME, FOREIGN KEY (CustomerId) REFERENCES Customers(CustomerId) ); GO -- Insert dummy data into Customers INSERT INTO Customers (CustomerId, Name, Email) VALUES (1, 'John Doe', 'john.doe@example.com'), (2, 'Jane Smith', 'jane.smith@example.com'); GO -- Insert dummy data into Orders INSERT INTO Orders (OrderId, CustomerId, OrderDate) VALUES (1, 1, GETDATE()), (2, 2, DATEADD(day, -1, GETDATE())); GO
Our business requirement is to fetch all the data from the Customers and Orders database table and then display it on the console. The following example exactly does the same using DataSet. In the example below, we created an instance of the DataSet and then filled out the dataset using the Fill method of the data adapter object. The following example is self-explained, so please go through the comment lines.
using Microsoft.Data.SqlClient; using System.Data; namespace ADODOTNETCoreDemo { class Program { static void Main(string[] args) { try { string connectionString = "Server=LAPTOP-6P5NK25R\\SQLSERVER2022DEV;Database=OrderDB;Trusted_Connection=True;TrustServerCertificate=True;"; DataSet dataSet = FetchDataFromDatabase(connectionString); DisplayData(dataSet); } catch (Exception ex) { Console.WriteLine($"Exception Occurred: {ex.Message}"); } } //Define a method to fetch data from the database and populate the DataSet static DataSet FetchDataFromDatabase(string connectionString) { string customersQuery = "SELECT * FROM Customers;"; string ordersQuery = "SELECT * FROM Orders;"; DataSet dataSet = new DataSet(); using (SqlConnection connection = new SqlConnection(connectionString)) { SqlDataAdapter adapter = new SqlDataAdapter(); // Fetch Customers adapter.SelectCommand = new SqlCommand(customersQuery, connection); adapter.Fill(dataSet, "Customers"); // Fetch Orders adapter.SelectCommand = new SqlCommand(ordersQuery, connection); adapter.Fill(dataSet, "Orders"); } return dataSet; } //Method to display the data static void DisplayData(DataSet dataSet) { Console.WriteLine("Customers:"); foreach (DataRow row in dataSet.Tables["Customers"].Rows) { Console.WriteLine($"ID: {row["CustomerId"]}, Name: {row["Name"]}, Email: {row["Email"]}"); } Console.WriteLine("\nOrders:"); foreach (DataRow row in dataSet.Tables["Orders"].Rows) { Console.WriteLine($"Order ID: {row["OrderId"]}, Customer ID: {row["CustomerId"]}, Order Date: {row["OrderDate"]}"); } } } }
This will connect to your SQL Server database, fetch data from the Customers and Orders tables, populate a DataSet with this data, and then display the data in the console. When you run the above code, you will get the following output:
Copy, Clone, and Clear Methods of DataSet in ADO.NET Core
Let’s use the Copy, Clone, and Clear methods of DataSet. These methods are useful for managing in-memory data representations:
- Copy(): Creates a new DataSet that is identical to the original, including all schema and data.
- Clone(): Creates a new DataSet with the same schema as the original but without any data.
- Clear(): Clears all data from the tables in the dataset but keeps the schema.
The following example shows how to use the Copy, Clone, and Clear Methods of the DataSet using ADO.NET Core. The example code is self-explained, so please go through the comment lines.
using Microsoft.Data.SqlClient; using System.Data; namespace ADODOTNETCoreDemo { class Program { static void Main(string[] args) { try { string connectionString = "Server=LAPTOP-6P5NK25R\\SQLSERVER2022DEV;Database=OrderDB;Trusted_Connection=True;TrustServerCertificate=True;"; DataSet originalDataSet = FetchDataFromDatabase(connectionString); // Display original data DisplayData(originalDataSet, "Original DataSet"); // Demonstrate Copy DataSet copiedDataSet = originalDataSet.Copy(); DisplayData(copiedDataSet, "Copied DataSet"); // Demonstrate Clone DataSet clonedDataSet = originalDataSet.Clone(); // To demonstrate that clone is schema only, try adding data manually or simply display it to show it's empty DisplayData(clonedDataSet, "Cloned DataSet (Schema Only)"); // Demonstrate Clear originalDataSet.Clear(); DisplayData(originalDataSet, "Cleared Original DataSet"); } catch (Exception ex) { Console.WriteLine($"Exception Occurred: {ex.Message}"); } } //Define a method to fetch data from the database and populate the DataSet static DataSet FetchDataFromDatabase(string connectionString) { DataSet dataSet = new DataSet(); using (SqlConnection connection = new SqlConnection(connectionString)) { SqlDataAdapter dataAdapter = new SqlDataAdapter("SELECT * FROM Customers; SELECT * FROM Orders;", connection); //Data Table 1 will be Customers data which is at Index Position 0 //Data Table 2 will be Orders data which is at Index Position 1 dataAdapter.Fill(dataSet); dataSet.Tables[0].TableName = "Customers"; dataSet.Tables[1].TableName = "Orders"; } return dataSet; } //Method to display the data static void DisplayData(DataSet dataSet, string title) { Console.WriteLine($"{title}:"); Console.WriteLine("Customers:"); foreach (DataRow row in dataSet.Tables["Customers"].Rows) { Console.WriteLine($"ID: {row["CustomerId"]}, Name: {row["Name"]}, Email: {row["Email"]}"); } Console.WriteLine("\nOrders:"); foreach (DataRow row in dataSet.Tables["Orders"].Rows) { Console.WriteLine($"Order ID: {row["OrderId"]}, Customer ID: {row["CustomerId"]}, Order Date: {row["OrderDate"]}"); } Console.WriteLine("-------------------------------------------------------------"); } } }
Explanation
- Original DataSet Display: Initially, we fetch data from the database and display the contents of our dataset, showing both customers and orders.
- Copy Demonstration: By copying the original dataset, we create a new instance that includes both the schema and the data. Displaying this copied dataset shows it contains the same data as the original.
- Clone Demonstration: Cloning the dataset creates a new instance with the same schema but no data. When we display this cloned dataset, it shows no records under customers or orders, demonstrating its schema-only.
- Clear Demonstration: Clearing the original dataset removes all data but retains the schema. Displaying the original dataset after clearing shows no records, indicating the data has been removed.
This application demonstrates how to work with DataSet methods Copy, Clone, and Clear in a .NET Core console application using ADO.NET Core, showcasing data manipulation and management in memory without affecting the database. When you run the above code, you will get the following output:
How Do We Remove a DataTable from ADO.NET Core DataSet?
Now, suppose you have a DataSet object which contains multiple data tables. If you initialize the data set object with null, all the data tables will be dropped. That means you cannot access the data tables anymore. But what is our requirement, instead of deleting all the data tables, I want to delete a specific data table and I still want to access other data tables. For this, we need to use the following Remove method.
- Remove(DataTable table): This method removes the specified DataTable object from the collection. Here, the parameter table specifies the DataTable to remove.
Note: We need to call the above Remove method on the Tables collection property of the DataSet object. Further, to avoid the Runtime exception, first, you need to check whether the DataSet contains the data table you are trying to remove.
Let us see how to remove the Orders Data Table from the DataSet using ADO.NET Core. Now, after fetching the data from the database and displaying it, we will remove the Orders table from the DataSet and display the DataSet content again to confirm the removal. So, modify the Program class as follows:
using Microsoft.Data.SqlClient; using System.Data; namespace ADODOTNETCoreDemo { class Program { static void Main(string[] args) { try { string connectionString = "Server=LAPTOP-6P5NK25R\\SQLSERVER2022DEV;Database=OrderDB;Trusted_Connection=True;TrustServerCertificate=True;"; DataSet dataSet = FetchDataFromDatabase(connectionString); // Display the original DataSet DisplayData(dataSet, "Original DataSet with Customers and Orders"); // Remove the Orders DataTable if (dataSet.Tables.Contains("Orders")) { dataSet.Tables.Remove("Orders"); Console.WriteLine("Orders table has been removed from the DataSet."); } // Display the DataSet after removing the Orders table DisplayData(dataSet, "DataSet after Removing Orders Table"); } catch (Exception ex) { Console.WriteLine($"Exception Occurred: {ex.Message}"); } } //Define a method to fetch data from the database and populate the DataSet static DataSet FetchDataFromDatabase(string connectionString) { DataSet dataSet = new DataSet(); using (SqlConnection connection = new SqlConnection(connectionString)) { SqlDataAdapter dataAdapter = new SqlDataAdapter("SELECT * FROM Customers; SELECT * FROM Orders;", connection); //Data Table 1 will be Customers data which is at Index Position 0 //Data Table 2 will be Orders data which is at Index Position 1 dataAdapter.Fill(dataSet); dataSet.Tables[0].TableName = "Customers"; dataSet.Tables[1].TableName = "Orders"; } return dataSet; } //Method to display the data static void DisplayData(DataSet dataSet, string title) { Console.WriteLine($"{title}:"); if (dataSet.Tables.Contains("Customers")) { Console.WriteLine("Customers:"); foreach (DataRow row in dataSet.Tables["Customers"].Rows) { Console.WriteLine($"ID: {row["CustomerId"]}, Name: {row["Name"]}, Email: {row["Email"]}"); } } if (dataSet.Tables.Contains("Orders")) { Console.WriteLine("\nOrders:"); foreach (DataRow row in dataSet.Tables["Orders"].Rows) { Console.WriteLine($"Order ID: {row["OrderId"]}, Customer ID: {row["CustomerId"]}, Order Date: {row["OrderDate"]}"); } } else { Console.WriteLine("\nOrders table does not exist."); } Console.WriteLine("---------------------------------------------------"); } } }
Explanation
- Original DataSet Display: Initially, the application fetches data from the database and displays the contents of the DataSet, which includes both the Customers and Orders tables.
- Remove the Orders DataTable: It checks if the Orders table exists within the DataSet. If it does, the table is removed using dataSet.Tables.Remove(“Orders”). A message is printed to the console to indicate the removal.
- Display After Removal: The application then displays the Data Set again. Since the Orders table has been removed, only the Customers table is shown, or a message indicating the Orders table does not exist, depending on the DataSet’s current state.
This example demonstrates how to programmatically remove a DataTable (Orders in this case) from a DataSet in a .NET Core application using ADO.NET Core. This operation dynamically adjusts the in-memory data structure based on runtime conditions or requirements without affecting the underlying database. When you run the above code, you will get the following output:
Batch Insert, Update, and Delete using DataSet:
To perform batch INSERT, UPDATE, and DELETE operations in ADO.NET Core using a DataSet, we will configure our SqlDataAdapter with appropriate command objects for each type of operation. This involves creating SQL commands that define how to insert new records, update existing ones, and delete records. The SqlDataAdapter will then use these commands to apply changes from your DataSet to the database in a batch process. Please modify the Program class as follows. For a better understanding, please go through the comment lines.
using Microsoft.Data.SqlClient; using System.Data; namespace ADODOTNETCoreDemo { class Program { static void Main(string[] args) { try { string connectionString = "Server=LAPTOP-6P5NK25R\\SQLSERVER2022DEV;Database=OrderDB;Trusted_Connection=True;TrustServerCertificate=True;"; DataSet dataSet = FetchDataFromDatabase(connectionString); // Modify DataSet for batch operations ModifyDataSetForBatchOperations(dataSet); // Apply changes to the database ApplyChangesToDatabase(dataSet, connectionString); } catch (Exception ex) { Console.WriteLine($"Exception Occurred: {ex.Message}"); } } //Define a method to fetch data from the database and populate the DataSet static DataSet FetchDataFromDatabase(string connectionString) { DataSet dataSet = new DataSet(); using (SqlConnection connection = new SqlConnection(connectionString)) { SqlDataAdapter dataAdapter = new SqlDataAdapter("SELECT * FROM Customers; SELECT * FROM Orders;", connection); //Data Table 1 will be Customers data which is at Index Position 0 //Data Table 2 will be Orders data which is at Index Position 1 dataAdapter.Fill(dataSet); dataSet.Tables[0].TableName = "Customers"; //Setting the Primary key DataColumn[] keyColumns = new DataColumn[1]; keyColumns[0] = dataSet.Tables[0].Columns["CustomerId"]; dataSet.Tables[0].PrimaryKey = keyColumns; dataSet.Tables[1].TableName = "Orders"; keyColumns = new DataColumn[1]; keyColumns[0] = dataSet.Tables[1].Columns["OrderId"]; dataSet.Tables[1].PrimaryKey = keyColumns; } return dataSet; } //We need to define SQL commands for INSERT, UPDATE, and DELETE operations. //These commands are used by the SqlDataAdapter to apply changes from the DataSet to the database. static void ConfigureBatchCommands(SqlDataAdapter adapter, SqlConnection connection) { // INSERT command adapter.InsertCommand = new SqlCommand("INSERT INTO Orders (OrderId, CustomerId, OrderDate) VALUES (@OrderId, @CustomerId, @OrderDate)", connection); adapter.InsertCommand.Parameters.Add("@OrderId", SqlDbType.Int, 0, "OrderId"); adapter.InsertCommand.Parameters.Add("@CustomerId", SqlDbType.Int, 0, "CustomerId"); adapter.InsertCommand.Parameters.Add("@OrderDate", SqlDbType.DateTime, 0, "OrderDate"); // UPDATE command adapter.UpdateCommand = new SqlCommand("UPDATE Orders SET OrderDate = @OrderDate WHERE OrderId = @OrderId", connection); adapter.UpdateCommand.Parameters.Add("@OrderDate", SqlDbType.DateTime, 0, "OrderDate"); adapter.UpdateCommand.Parameters.Add("@OrderId", SqlDbType.Int, 0, "OrderId"); // DELETE command adapter.DeleteCommand = new SqlCommand("DELETE FROM Orders WHERE OrderId = @OrderId", connection); adapter.DeleteCommand.Parameters.Add("@OrderId", SqlDbType.Int, 0, "OrderId"); } //Next, modify the DataSet to include changes for INSERT, UPDATE, and DELETE operations. //This involves adding new rows, updating existing rows, and marking rows for deletion: static void ModifyDataSetForBatchOperations(DataSet dataSet) { DataTable ordersTable = dataSet.Tables["Orders"]; // Insert new orders DataRow newRow = ordersTable.NewRow(); newRow["OrderId"] = 3; // Assuming 3 is a new ID. Adjust according to your data. newRow["CustomerId"] = 1; // Assuming the CustomerId is valid. newRow["OrderDate"] = DateTime.Now; ordersTable.Rows.Add(newRow); // Update an existing order's date DataRow existingRow = ordersTable.Rows.Find(1); // Assuming an order with OrderId 1 exists if (existingRow != null) { existingRow["OrderDate"] = DateTime.Now.AddDays(1); // Update to a new date } // Mark an order for deletion DataRow rowToDelete = ordersTable.Rows.Find(2); // Assuming an order with OrderId 2 exists if (rowToDelete != null) { rowToDelete.Delete(); } } //After modifying the DataSet, use a SqlDataAdapter to apply these changes to the database. //This involves opening a connection, configuring batch commands, and //then using the Update method to apply the changes static void ApplyChangesToDatabase(DataSet dataSet, string connectionString) { using (SqlConnection connection = new SqlConnection(connectionString)) { SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Orders WHERE 1=0", connection); ConfigureBatchCommands(adapter, connection); connection.Open(); using (SqlTransaction transaction = connection.BeginTransaction()) { adapter.SelectCommand.Transaction = transaction; adapter.InsertCommand.Transaction = transaction; adapter.UpdateCommand.Transaction = transaction; adapter.DeleteCommand.Transaction = transaction; try { adapter.Update(dataSet, "Orders"); transaction.Commit(); Console.WriteLine("Database updated successfully."); } catch (Exception ex) { Console.WriteLine($"An error occurred: {ex.Message}"); transaction.Rollback(); } } } } } }
Explanation:
Let’s break down the explanation for each of the methods ConfigureBatchCommands, ModifyDataSetForBatchOperations, and ApplyChangesToDatabase within the context of performing batch operations (INSERT, UPDATE, DELETE) using a DataSet and a SqlDataAdapter in ADO.NET.
ConfigureBatchCommands Method
This method is responsible for setting up the SQL commands that the SqlDataAdapter will use to perform batch operations on the database. Each type of operation (INSERT, UPDATE, DELETE) needs a corresponding SqlCommand configured with the appropriate SQL statement and parameters.
- INSERT Command: Specifies how new records should be inserted into the database. Parameters (@OrderId, @CustomerId, @OrderDate) are mapped to the respective columns of the Orders table.
- UPDATE Command: Defines how existing records should be updated. The @OrderId parameter is used to identify which record to update, and @OrderDate is the new value for the OrderDate column.
- DELETE Command: Indicates how records should be deleted. The @OrderId parameter identifies which record to remove from the database.
ModifyDataSetForBatchOperations Method
This method simulates modifications to the Data Set to demonstrate how batch operations are prepared before being applied to the database. It involves adding a new row (INSERT), updating an existing row (UPDATE), and marking a row for deletion (DELETE).
- Insert: A new DataRow is created, populated with data, and added to the Orders table in the DataSet.
- Update: An existing row is found using the primary key and modified.
- Delete: An existing row is marked for deletion by calling the Delete method on the DataRow.
ApplyChangesToDatabase Method
This method applies the changes made in the Data Set to the actual database using a transaction. It ensures that all operations are completed successfully or rolled back in case of an error, maintaining database integrity.
- The SqlDataAdapter is configured with the previously defined commands for INSERT, UPDATE, and DELETE.
- A transaction is started before the updates are applied to ensure all changes are applied atomically.
- The Update method of the adapter is called with the modified DataSet, which applies all changes to the database.
- The transaction is committed if the update is successful; otherwise, it is rolled back to maintain data consistency.
This process will perform batch INSERT, UPDATE, and DELETE operations based on your modifications to the DataSet. The SqlDataAdapter manages these operations in a batch, efficiently syncing your in-memory data changes back to the database. When you run the above code, you will get the output: Database updated successfully.
When to Use ADO.NET Core DataSet?
ADO.NET Core DataSet is a feature of ADO.NET designed for applications that need to work with data in a disconnected manner. It is a collection of Data Tables and other objects that can be used to represent relational data in memory. Using ADO.NET Core DataSet can be particularly beneficial in the following scenarios:
- Disconnected Data Access: When your application needs to work with data without maintaining a constant connection to the database. DataSet allows you to fetch data, work with it, and then reconnect to update the database as needed. This is particularly useful in environments with intermittent connectivity or when minimizing database connections is a priority.
- Complex Data Handling: DataSet is well-suited for dealing with complex data relationships, including hierarchical data. It can represent relational data in memory and allows you to navigate and manage data relationships using DataRelation and ForeignKeyConstraint objects.
- Batch Operations: If your application needs to perform batch updates, insertions, or deletions, DataSet can be a good choice. You can make multiple changes to the data in memory and then submit all those changes to the database in a single transaction. This can improve performance by reducing the number of round-trips to the database.
- Client-side Data Manipulation: DataSet allows for sophisticated data manipulation on the client side, including sorting, filtering, and searching operations, without requiring additional database queries. This can improve application responsiveness and reduce server load.
- Data Binding: DataSet works well with data-binding features in many GUI frameworks, making displaying and interacting with data in user interfaces easier. It supports complex data binding scenarios, including master-detail forms.
- Cross-Platform Applications: With the advent of .NET Core and its cross-platform capabilities, using ADO.NET Core DataSet in applications ensures that your data handling logic can run on multiple platforms, including Windows, Linux, and macOS.
- XML Integration: DataSet supports XML, allowing you to load and write XML data easily. This is useful for web services, data exchange between applications, and scenarios where data needs to be persisted in an easily readable and portable format.
In the next article, I will discuss ADO.NET Core SqlCommandBuilder with Examples. In this article, I explain ADO.NET Core DataSet with Examples. I would like to have your feedback. Please post your feedback, questions, or comments about this ADO.NET Core DataSet with Examples article.