Filtering Null values in Select

前端 未结 4 848
悲&欢浪女
悲&欢浪女 2020-12-08 18:06

I have IQueryable list of objects of type T which I want to transform into objects of type K

List tranformedList = originalList.Select(x => trans         


        
4条回答
  •  没有蜡笔的小新
    2020-12-08 18:41

    Use Where Instead of Select (Linq).

    Where returns the list without null values directly

    List tranformedList = originalList.Where(x => x != null).ToList();

提交回复
热议问题