PocoEmit.Collections
0.6.2.1-alpha
.NET 7.0
This package targets .NET 7.0. The package is compatible with this framework or higher.
.NET Standard 1.1
This package targets .NET Standard 1.1. The package is compatible with this framework or higher.
.NET Framework 4.5
This package targets .NET Framework 4.5. The package is compatible with this framework or higher.
This is a prerelease version of PocoEmit.Collections.
dotnet add package PocoEmit.Collections --version 0.6.2.1-alpha
NuGet\Install-Package PocoEmit.Collections -Version 0.6.2.1-alpha
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="PocoEmit.Collections" Version="0.6.2.1-alpha" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PocoEmit.Collections" Version="0.6.2.1-alpha" />
<PackageReference Include="PocoEmit.Collections" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PocoEmit.Collections --version 0.6.2.1-alpha
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PocoEmit.Collections, 0.6.2.1-alpha"
#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.
#:package PocoEmit.Collections@0.6.2.1-alpha
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PocoEmit.Collections&version=0.6.2.1-alpha&prerelease
#tool nuget:?package=PocoEmit.Collections&version=0.6.2.1-alpha&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Emit集合扩展
复制和转化集合对象
一、Mapper启用集合扩展
1. 对单个Mapper启用集合扩展
Mapper.Default.UseCollection();
2. 全局启用集合扩展
CollectionContainer.GlobalUseCollection();
二、转化
1. 直接转化
调用Convert方法
User[] source = [new User { Id = 1, Name = "Jxj" }, new User { Id = 2, Name = "张三" }];
IList<UserDTO> result = _mapper.Convert<User[], IList<UserDTO>>(source);
Dictionary<int, User> source = new() { { 1, new User { Id = 1, Name = "Jxj" } } };
Dictionary<int, UserDTO> result = _mapper.Convert<Dictionary<int, User>, Dictionary<int, UserDTO>>(source);
List<User> source = [new User { Id = 1, Name = "Jxj" }, new User { Id = 2, Name = "张三" }];
Dictionary<int, UserDTO> result = _mapper.Convert<List<User>, Dictionary<int, UserDTO>>(source);
2. 用委托
调用GetConvertFunc方法
IList<User> source = [new User { Id = 1, Name = "Jxj" }, new User { Id = 2, Name = "张三" }];
var converter = _mapper.GetConvertFunc<IList<User>, UserDTO[]>();
UserDTO[] result = converter(source);
3. 用接口
调用GetConverter方法
IList<AutoUserDTO> source = [new AutoUserDTO { UserId = "222", UserName = "Jxj" }, new AutoUserDTO { UserId = "333", UserName = "李四" }];
var converter = mapper.GetConverter<IList<AutoUserDTO>, User[]>();
var result = converter.Convert(source);
三、复制
1. 直接复制
调用Copy方法
User[] source = [new User { Id = 1, Name = "Jxj" }, new User { Id = 2, Name = "张三" }];
List<UserDTO> result = [];
_mapper.Copy(source, result);
2. 用委托
调用GetCopyAction方法
User[] source = [new User { Id = 1, Name = "Jxj" }, new User { Id = 2, Name = "张三" }];
List<UserDTO> result = [];
var copyAction = _mapper.GetCopyAction<User[], List<UserDTO>>();
copyAction(source, result);
3. 用接口
调用GetCopier方法
AutoUserDTO[] source = [new AutoUserDTO { UserId = "222", UserName = "Jxj" }, new AutoUserDTO { UserId = "333", UserName = "李四" }];
IList<User> result = [];
var copier = mapper.GetCopier<AutoUserDTO[], IList<User>>();
copier.Copy(source, result);
四、字典复制强化
1. DictionaryCopy方法
复制实体成员到object字典
User user = new() { Id = 3, Name = "张三" };
var dic = new Dictionary<string, object>();
_mapper.DictionaryCopy(user, dic);
2. GetDictionaryCopyAction方法
复制实体成员到object字典
var action = _mapper.GetDictionaryCopyAction<User>();
User user = new() { Id = 3, Name = "张三" };
var dic = new Dictionary<string, object>();
action(user, dic);
3. CreatetDictionaryCopyAction方法
- 委托编译生成,重复使用需要缓存
- 递归复制指定类型成员
- 支持同类型字典
- 不支持数组和其他集合
- 相当于彻底平铺展开
var action = _mapper.CreatetDictionaryCopyAction<Student, Dictionary<string, string>>();
Student source = new()
{
User = new() { Id = 2, Name = "Jxj" },
Role = "班长",
Skills = new() { { "足球", "很好" }, { "篮球", "优秀" } }
};
var result = new Dictionary<string, string>();
action(source, result);
// result.Count == 4
var action = _mapper.CreatetDictionaryCopyAction<Student, Dictionary<string, int>>();
Student source = new()
{
User = new() { Id = 2, Name = "Jxj" },
Age = 17,
Scores = new() { { "语文", 95 }, { "数学", 96 } }
};
var dic = new Dictionary<string, int>();
action(source, dic);
// result.Count == 4
4. CreatetDictionaryCopyAction重载方法
- 委托编译生成,重复使用需要缓存
- 递归复制指定类型成员并转化为另一类型
- 支持同类型数组
- 不支持数组和其他集合
- 相当于彻底平铺展开
var action = _mapper.CreatetDictionaryCopyAction<Student, int, IDictionary<string, string>>();
Assert.NotNull(action);
Student source = new()
{
User = new() { Id = 2, Name = "Jxj" },
Age = 17,
Scores = new() { { "语文", 95 }, { "数学", 96 } }
};
var dic = new Dictionary<string, string>();
action(source, dic);
// result.Count == 4
五、字典转化强化
1. ToDictionary
实体成员转化为object字典
User user = new() { Id = 3, Name = "张三" };
IDictionary<string, object> dic = _mapper.ToDictionary(user);
2. GetToDictionaryFunc
实体成员转化为object字典
var func = _mapper.GetToDictionaryFunc<User>();
User user = new() { Id = 3, Name = "张三" };
IDictionary<string, object> dic = func(user);
3. FromDictionary
object字典转化为实体
Dictionary<string, object> dic = new() { { nameof(User.Id), "3" }, { nameof(User.Name), "张三" } };
User user = _mapper.FromDictionary<User>(dic);
4. GetFromDictionaryFunc
object字典转化为实体
var func = _mapper.GetFromDictionaryFunc<User>();
Dictionary<string, object> dic = new() { { nameof(User.Id), "3" }, { nameof(User.Name), "张三" } };
User user = func(dic);
5. CreateDictionaryConvertFunc
- 委托编译生成,重复使用需要缓存
- 递归转化指定类型成员为字典
- 支持同类型字典
- 不支持数组和其他集合
- 相当于彻底平铺展开
var func = _mapper.CreateDictionaryConvertFunc<Student, Dictionary<string, int>>();
Student source = new()
{
User = new() { Id = 2, Name = "Jxj" },
Age = 17,
Scores = new() { { "语文", 95 }, { "数学", 96 } }
};
Dictionary<string, int> result = func(source);
// result.Count == 4
6. CreateDictionaryConvertFunc重载方法
- 委托编译生成,重复使用需要缓存
- 递归转化指定类型成员为字典
- 支持同类型字典
- 不支持数组和其他集合
- 相当于彻底平铺展开
var func = _mapper.CreateDictionaryConvertFunc<Student, int, IDictionary<string, string>>();
Student source = new()
{
User = new() { Id = 2, Name = "Jxj" },
Age = 17,
Scores = new() { { "语文", 95 }, { "数学", 96 } }
};
IDictionary<string, string> result = func(source);
// result.Count == 4
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. 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 is compatible. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.1 is compatible. netstandard1.2 was computed. netstandard1.3 is compatible. netstandard1.4 was computed. netstandard1.5 was computed. netstandard1.6 was computed. netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Windows Phone | wpa81 was computed. |
Windows Store | netcore was computed. netcore45 was computed. netcore451 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.5
- PocoEmit (>= 0.6.2.1-alpha)
- PocoEmit.Mapper (>= 0.6.2.1-alpha)
-
.NETStandard 1.1
- NETStandard.Library (>= 1.6.1)
- PocoEmit (>= 0.6.2.1-alpha)
- PocoEmit.Mapper (>= 0.6.2.1-alpha)
- System.Linq.Expressions (>= 4.3.0)
- System.Reflection (>= 4.3.0)
-
.NETStandard 1.3
- NETStandard.Library (>= 1.6.1)
- PocoEmit (>= 0.6.2.1-alpha)
- PocoEmit.Mapper (>= 0.6.2.1-alpha)
- System.Linq.Expressions (>= 4.3.0)
- System.Reflection (>= 4.3.0)
-
.NETStandard 2.0
- PocoEmit (>= 0.6.2.1-alpha)
- PocoEmit.Mapper (>= 0.6.2.1-alpha)
-
.NETStandard 2.1
- PocoEmit (>= 0.6.2.1-alpha)
- PocoEmit.Mapper (>= 0.6.2.1-alpha)
-
net7.0
- PocoEmit (>= 0.6.2.1-alpha)
- PocoEmit.Mapper (>= 0.6.2.1-alpha)
-
net8.0
- PocoEmit (>= 0.6.2.1-alpha)
- PocoEmit.Mapper (>= 0.6.2.1-alpha)
-
net9.0
- PocoEmit (>= 0.6.2.1-alpha)
- PocoEmit.Mapper (>= 0.6.2.1-alpha)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
0.6.2.1-alpha | 98 | 9/4/2025 |
0.6.2-alpha | 96 | 9/4/2025 |
0.6.1.1-alpha | 157 | 8/28/2025 |
0.6.1-alpha | 158 | 8/28/2025 |
0.6.0.3-alpha | 159 | 8/27/2025 |
0.6.0.2-alpha | 158 | 8/27/2025 |
0.6.0.1-alpha | 159 | 8/27/2025 |
0.6.0-alpha | 249 | 8/25/2025 |
0.5.2-alpha | 94 | 8/17/2025 |
0.5.1-alpha | 120 | 8/14/2025 |
0.5.0-alpha | 124 | 8/12/2025 |