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框架及其子框架很多, ...
随机推荐
- 怎样在QML中利用Sprite来做我们须要的动画
在游戏中动画的设计很中要. 在QML中,它提供了丰富的animation.可是有时我们须要对图像进行变化,就像放电影一样.在今天的这篇文章中,我们将设计一个能够变化图像的动画. 我们能够通过Qt所提供 ...
- ios对于枚举的使用
引言: 枚举值 它是一个整形(int) 并且,它不参与内存的占用和释放,枚举定义变量即可直接使用,不用初始化. 在代码中使用枚举的目的只有一个,那就是增加代码的可读性. 使用: 枚举的定义如下: t ...
- HDU 5438 Ponds
Ponds Time Limit: 1500/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Sub ...
- Caused by: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.st.mapper.UserMapper.userBaseMap
mybatis出现此异常,可能是因为 ***Mapper.xml 文件中存在重名对象,一不小心重复启动了mybatis的逆向工程. 以为会覆盖掉以前生成的,没想到是新生成的和之前生成的重复了 解决:把 ...
- Java 猫扑(mop)打卡小应用
唉 mop又没打卡,前面十几天全没啦,像我们这些IT码农虽然天天上网,但是总是忘记打卡,这不一失足生成千古恨,失败了撒.好不容易每次打卡都能得几百份的,唉.1. [代码][Java]代码 pac ...
- python中PIL.Image和OpenCV图像格式相互转换
PIL.Image转换成OpenCV格式: import cv2 from PIL import Image import numpy image = Image.open("plane.j ...
- java 后台的学习步骤
一.JavaWeb部分 第一阶段:JavaWeb前端技术 web前端技术 HTML, CSS, JavaScript基础, jQuery基础, BootStrap. 第二阶段:服务器端技术 Mysql ...
- Java中Semaphore(信号量) 数据库连接池
计数信号量用来控制同时访问某个特定资源的操作数或同时执行某个指定操作的数量 A counting semaphore.Conceptually, a semaphore maintains a set ...
- 【转】 IntelliJ IDEA 中 Project 和 Module 的概念及区别
原文地址:https://blog.csdn.net/qq_35246620/article/details/65448689 在 IntelliJ IDEA 中,没有类似于 Eclipse 工作空间 ...
- 【旧文章搬运】ZwQuerySystemInformation枚举进线程信息
原文发表于百度空间,2008-10-15========================================================================== 很古老的东 ...