EmitMapper系列之一:EmitMapper入门
EmitMapper的总结
EmitMapper简介
前言:
参考官网: http://emitmapper.codeplex.com/
Project Description
Powerful customisable tool for mapping entities to each other. Entities can be plain objects, DataReaders, SQL commands and anything you need. The tool uses run-time code
generation via the Emit library. It is usefull for dealing with DTO objects, data access layers an so on. 官方原文翻译:
项目描述
用于将实体映射到彼此的强大的可定制工具。实体可以是纯对象,DataReaders,SQL命令以及任何您需要的。该工具通过Emit库生成运行时代码。处理DTO对象,数据访问层等都是有用的。
优点:
我们看看官方怎么说???我想官方给了四点足以让你在相应的项目中使用它
- Extremely fast. It effectively uses the Emit library to generate mappers at run-time direct in IL as though these mappers are written by hand. Most other mappers use the Reflection library for mapping (or source code generation). Also EmitMapper minimizes boxing-unboxing operations and additional calls during mapping. For example it performs type conversion for value-types without boxing-unboxing and converts nested members without recursion (one-pass algorithm) when it is possible.
- Easy to use. Emit Mapper produces mappers at run time and there is no need for special complex build process unlike some other libraries which perform source code generation. Emit Mapper API is as simple as possible. You don't need to create any tedious XML document, or scatter strange attributes on your objects. Mapper can be created by one method call. But if you need fine-grained mapping configuration, you can easily reach it.
- Flexible. Emit Mapper doesn't have any hardcoded mapping strategy (special mapping attributes, XML documents or whatever) unlike most other mapping libraries. Instead, Emit Mapper has extremely flexible API and you can define any mapping yourself. For example you can define automatic mapping for DataReader to your business-objects. In general, Emit Mapper can be used as high performance tool for dynamic access to object properties and fields.
- Multi-Platform. The Emit Mapper can be run on Microsoft .NET Framework, Silverlight and Mono
官方给出四个优点
- 非常快 它有效地使用Emit库在IL中直接在运行时生成映射器,就好像这些映射器是用手写的。大多数其他映射器使用Reflection库进行映射(或源代码生成)。此外,EmitMapper还可以最大限度地减少打击拆箱操作和映射期间的其他调用。例如,对于没有打包装箱的值类型,它执行类型转换,并在可能时转换嵌套成员而不进行递归(一次通过算法)。
- 使用方便。Emit Mapper在运行时生成映射器,与执行源代码生成的其他库不同,不需要特殊的复杂构建过程。Emit Mapper API尽可能简单。您不需要创建任何繁琐的XML文档,或在对象上散布奇怪的属性。Mapper可以通过一种方法调用创建。但是,如果您需要细粒度的映射配置,您可以轻松实现。
- 灵活。与大多数其他映射库不同,Emit Mapper没有任何硬编码映射策略(特殊映射属性,XML文档或其他任何内容)。相反,Emit Mapper具有非常灵活的API,您可以自己定义任何映射。例如,您可以为DataReader定义自动映射到业务对象。通常,Emit Mapper可以用作动态访问对象属性和字段的高性能工具。
- 多平台。Emit Mapper可以在Microsoft .NET Framework,Silverlight和Mono上运行。
类型转换:
Emit Mapper can automatic convert the following types:
- Anything to string using the ToString() method.
- Primitive types using System.Convert class.
- Nullable types to value types and vice-versa.
- Enum to its underlying type and vice-versa.
- Enum to string and vice-versa.
- Collections of different types to each other (arrays, ArrayList, List<>, IEnumerable)
- classes to structures and vice-versa.
- Complex types with complex nested members using recursive mapping with shallow or deep copieng.
Emit Mapper可以自动转换以下类型:
- 任何使用ToString()方法进行字符串处理。
- 使用System.Convert类的基本类型。
- Nullable类型对值类型,反之亦然。
- 枚举为其底层类型,反之亦然。
- 枚举到字符串,反之亦然。
- 不同类型的集合(数组,ArrayList,List <>,IEnumerable)
- 类到结构,反之亦然。
- 具有复杂嵌套成员的复杂类型使用具有浅或深对应的递归映射。
总结:官方的描述,也可以在面试过程中进行简述,加分项。。。。。
- 博主是利用读书、参考、引用、抄袭、复制和粘贴等多种方式打造成自己的纯镀 24k 文章,请原谅博主成为一个无耻的文档搬运工!
- 小弟刚迈入博客编写,文中如有不对,欢迎用板砖扶正,希望给你有所帮助。
EmitMapper系列之一:EmitMapper入门的更多相关文章
- 分布式学习系列【dubbo入门实践】
分布式学习系列[dubbo入门实践] dubbo架构 组成部分:provider,consumer,registry,monitor: provider,consumer注册,订阅类似于消息队列的注册 ...
- 「译」JUnit 5 系列:基础入门
原文地址:http://blog.codefx.org/libraries/junit-5-basics/ 原文日期:25, Feb, 2016 译文首发:Linesh 的博客:JUnit 5 系列: ...
- SpringBoot系列: RestTemplate 快速入门
====================================相关的文章====================================SpringBoot系列: 与Spring R ...
- Go基础系列:channel入门
Go channel系列: channel入门 为select设置超时时间 nil channel用法示例 双层channel用法示例 指定goroutine的执行顺序 channel基础 chann ...
- elk系列1之入门安装与基本操作【转】
preface 我们每天都要查看服务器的日志,一方面是为了开发的同事翻找日志,另一方面是巡检服务器查看日志,而随着服务器数量以及越来越多的业务上线,日志越来越多,人肉运维相当痛苦了,此时,参考现在非常 ...
- Velocity魔法堂系列一:入门示例(转)
Velocity魔法堂系列一:入门示例 一.前言 Velocity作为历史悠久的模板引擎不单单可以替代JSP作为Java Web的服务端网页模板引擎,而且可以作为普通文本的模板引擎来增强服务端程序文本 ...
- 学习笔记之盘一盘 Python 系列 1 & 2 - 入门篇
盘一盘 Python 系列 1 & 2 - 入门篇 https://mp.weixin.qq.com/s?__biz=MzIzMjY0MjE1MA==&mid=2247486473&a ...
- Flask开发系列之快速入门
Flask开发系列之快速入门 文档 一个最小的应用 调试模式 路由 变量规则 构造 URL HTTP 方法 静态文件 模板渲染 访问请求数据 环境局部变量 请求对象 文件上传 Cookies 重定向和 ...
- SpringBoot系列之从入门到精通系列教程
对应SpringBoot系列博客专栏,例子代码,本博客不定时更新 Spring框架:作为JavaEE框架领域的一款重要的开源框架,在企业应用开发中有着很重要的作用,同时Spring框架及其子框架很多, ...
随机推荐
- node封装mysql模块
node是基于异步的,因此在进行数据库查询操作的通常是通过回调来操作查询结果.但是在有了es7的async/await,基本不再需要回调了,所以本篇是基于async/await对mysql进行一次操作 ...
- SDUT OJ 2892 A (字典树问题-输出出现次数最多的字符串的出现次数,60ms卡时间,指针+最后运行完释放内存)
A Time Limit: 60ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 给出n(1<= n && n <= 2*10^6)个字 ...
- Could not load file or assembly 'System.Web.Http
使用FusLogVw https://stackoverflow.com/questions/4469929/could-not-load-file-or-assembly-or-one-of-its ...
- 织梦CMS首页、列表页文章如何调出该文章TAG标签?
1.如果是dedecms v5.7版本直接使用标签 [field:id function=GetTags(@me)/] 就可以调用出来了.只不过不带连接的. 2.如果需要连接请注释掉include/h ...
- ewasm项目初探
为了改进EVM1.0,以太坊的新一代虚拟机项目ewasm (github.com/ewasm)将支持WebAssembly(wasm),wasm在性能,扩展性,开发工具,社区都更有优势.除以太坊外,一 ...
- NOIP2004题解
传送门 考查题型 dp 搜索 模拟 数据结构堆 贪心 T1 津津的储蓄计划 题目描述 津津的零花钱一直都是自己管理.每个月的月初妈妈给津津300元钱,津津会预算这个月的花销,并且总能做到实际花销和 ...
- bzoj2431逆序对数列——递推
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2431 考虑新加入一个数i,根据放的位置不同,可以产生0~i-1个新逆序对: 所以f[i][j ...
- .NETFramework:Stopwatch
ylbtech-.NETFramework:Stopwatch 1.返回顶部 1. #region 程序集 System, Version=4.0.0.0, Culture=neutral, Publ ...
- hdu5822 color
首先考虑假如是树上的做法:考虑dp,f(i)表示对i的子树染色的方案数.用hash可以实现查询两棵子树是否相同.从而根据hash值排序分类,将相同的子树放在一类. (1)f(i)等于每一类的f(p)乘 ...
- Start Developing Mac Apps -- App Design 应用程序设计
App Design Apps do not exist on their own. They not only interact seamlessly with their environment, ...