【发布时间】:2019-07-20 19:30:37
【问题描述】:
我是 C# 新手,我想在 Web API 中将模型类对象转换为 DataTable。
模型类
public class Employee_Master_Model
{
public string UserType { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string MiddleName { get; set; }
public string Mobile { get; set; }
public string Phone { get; set; }
public string Email { get; set; }
public bool IsActive { get; set; }
public int EmployeeId { get; set; }
}
控制器:
public async Task<IActionResult> CreateEmployee([FromBody] Employee_Master_Model employee_Master_Model)
{
try
{
// Need to convert the object (employee_Master_Model) to DataTable
}
catch (Exception ex)
{
throw ex;
}
}
尝试了好几个小时都无法完成。谁能帮我解决这个问题。
【问题讨论】:
-
“试了好几个小时都做不成”是什么意思?
-
你尝试了什么?
-
你想使用 ADO.NET 还是 Entity Framework?
标签: c# .net asp.net-web-api asp.net-core