C# 使用c将数据表动态转换为类对象#

C# 使用c将数据表动态转换为类对象#,c#,asp.net,.net,C#,Asp.net,.net,在.Net中是否存在可以将数据表转换为poco类对象的内置方法 为了更好地理解我的场景,请浏览下面的内容 我有一个特殊的要求,我会得到多个数据表,如下所示 Name || Value --------------------------------------- DashboardName || DashBoard1 myparam1 || abc myparam2

在.Net中是否存在可以将数据表转换为poco类对象的内置方法

为了更好地理解我的场景,请浏览下面的内容

我有一个特殊的要求,我会得到多个数据表,如下所示

Name                 ||         Value
---------------------------------------
DashboardName        ||         DashBoard1
myparam1             ||         abc
myparam2             ||         def
myparam3             ||         xyz
type                 ||         MyClass


Name                    ||         Value
    ---------------------------------------
    DashboardName        ||         DashBoard2
    myparamnew           ||         abc
    myparamnew2          ||         def
    myparamnew3          ||         xyz
    type                 ||         MyClass2
我有两节课

public class MyClass
{
  public string myparam1{ get; set; }
  public string myparam2{ get; set; }
  public string myparam3{ get; set; }
}

public class MyClass2
{
 public string myparamnew1{ get; set; }
 public string myparamnew2{ get; set; }
 public string myparamnew3{ get; set; }
}
因此,基于datatable的类型值,我想将datatable转换为特定于类型的类


有人能指导我朝着正确的方向去实现我的目标吗?

据我所知,在.Net中没有内置方法,但有一些第三方支持或支持

如果您不想使用第三方库,可以尝试使用T4模板来实现

第三方。。

可能会有帮助