Làm thế nào để định nghĩa cấu trúc DataSet?
Làm thế nào để định nghĩa cấu trúc DataSet?
Định nghĩa cấu trúc DataSet (schema: bảng, cột, khoá, ràng buộc, quan hệ):
var ds = new DataSet("Shop");
var customers = ds.Tables.Add("Customers");
customers.Columns.Add("Id", typeof(int)).AutoIncrement = true;
customers.Columns.Add("Name", typeof(string)).MaxLength = 100;
customers.PrimaryKey = new[] { customers.Columns["Id"]! };
var orders = ds.Tables.Add("Orders");
orders.Columns.Add("Id", typeof(int)); orders.Columns.Add("CustomerId", typeof(int)); orders.Columns.Add("Total", typeof(decimal));
Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.