原文 automapper如何全局配置map条件过滤null值空值对所有映射起效 我们在使用automapper的时候经常会遇到这样的问题:假设展示给用户的数据我们用UserDto类,User类就是我们的实体类.在给用户编辑的时候,我们可能某些字段在数据库中为Null,这时候需要一些默认值 比如这里UserDto中的BirTime,然后我们有一些人的习惯是在构造函数里面进行赋值 public class User { public int Id { get; set; } public stri
HashMap存储自定义类型键值 1.当给HashMap中存放自定义对象时,如果自定义对象是键存在,保证键唯一,必须复写对象的hashCode和equals方法. 2.如果要保证map中存放的key和取出的顺序一致,可使用LinkedHashMap集合来存放 public class Person { private String name; private int age; public Person(String name, int age) { super(); //有参构造 this.n
public static String getCityId(HashMap<String,String> citys, String city){ Set set = citys.entrySet();//新建一个不可重复的集合 ArrayList<String> arr = new ArrayList<String>();//新建一个集合 Iterator it = set.iterator();//遍历的类 while(it.hasNext()) { Map.En
在hive中,我们经常会遇到对某列进行count.sum.avg等操作计算记录数.求和.求平均值等,但这列经常会出现有null值的情况,那这些操作会不会过滤掉null能呢? 下面我们简单测试下: with tmp as(select null as col1 union allselect 666 as col1 union allselect 999 as col1)select avg(col1) avg_numm, sum(col1) sum_num, count(1) cnt, coun
public T Update<T>(T entity) where T : ModelBase { var set = this.Set<T>(); set.Attach(entity); foreach (System.Reflection.PropertyInfo p in entity.GetType().GetProperties()) { if (p.GetValue(entity) != null) { this.Entry<T>(entity).Prop
之前我们看过了两种类型的集合,ArrayList集合和LinkedList集合,两种集合各有优势,我们不具体说了,但是本篇要看的集合可以完成它们完成不了的任务.比如:现有一篇文章,要你统计其中出现了哪些单词,每个单词总共出现了几次.这个问题很明显需要记录两个变量(某单词及其出现次数),但是我们之前介绍的集合都只能同时存储一种类型的变量,无法实现对应的效果. 我们的HashMap又可以叫做键值对集合(官方名称映射),比如: public class Test_Class { public