EntityMappingDB 1.4.8

dotnet add package EntityMappingDB --version 1.4.8                
NuGet\Install-Package EntityMappingDB -Version 1.4.8                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EntityMappingDB" Version="1.4.8" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EntityMappingDB --version 1.4.8                
#r "nuget: EntityMappingDB, 1.4.8"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install EntityMappingDB as a Cake Addin
#addin nuget:?package=EntityMappingDB&version=1.4.8

// Install EntityMappingDB as a Cake Tool
#tool nuget:?package=EntityMappingDB&version=1.4.8                

EntityMappingDB

1.采用emit方法DataTable,IDataReader与实体相互转换。

2.DataTable,IDataReader转换实体: ToEntityList扩展方法

3.实体转换DataTable: FromEntityToTable扩展方法

4.如果实体转换DataTable带有特性: FromEntityToTableAttribute扩展方法

设计了三类特性ColumnType(列类型映射),DataField(列名称映射),NoColumn(没有对应的列,忽略该属性)
5.nuget
EntityMappingDB


使用
1.datatable

        DataTable dt = new DataTable();    
        dt.Columns.Add("Id", typeof(int));  
        dt.Columns.Add("DTO", typeof(string));  
        dt.Rows.Add(1, "3e-6");  
        dt.Rows.Add(2, "5000");  

      List<Person> lst=  dt.ToEntityList<Person>(); //转model  

      DataTable dd=  lst.FromEntityToTable();//转回DataTable  

2.IDataReader

        IDataReader idr = null;    
        List<Person> lstm=  idr.ToEntityList<Person>();  //转model   
        DataTable dds=   lstm.FromEntityToTableAttribute<Person>();  //转回DataTable

定义:

public class Person  
{  
    public int Id { get; set; }  

    [ColumnType(typeof(double))]  
    public decimal? DTO { get; set; }  

    [DataField("user")]  
    public string Name { get; set; }  
}  

说明:
1.如果程序报错:没有找到列,则说明你使用了不同的datatable数据转同样model,但是这些数据不一样。这时你可以使用重载方法,定一个唯一key

2.不出意外,该项目没有升级的必要,除非emit技术有更新

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on EntityMappingDB:

Package Downloads
Hikari.Integration.Entity

实体转换(采用Emit,DataTable,DataReader与List<T>相互转换) 替换其它扩展库 个人贡献,任意使用,希望保留版本和作者注释

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.4.8 168 9/27/2023
1.4.7 173 5/16/2023
1.4.6 197 4/19/2023
1.4.5 503 10/2/2021
1.4.4 480 7/6/2020
1.4.3 490 4/20/2020
1.3.3 498 3/20/2020
1.3.2 471 3/19/2020
1.3.0 450 3/11/2020
1.2.2 506 2/15/2020
1.2.1 545 2/12/2020
1.1.1 674 4/6/2019
1.1.0 1,432 3/20/2019

优化缓存