1. 程式人生 > >又學一招——linq 之 select 動態

又學一招——linq 之 select 動態

新增名稱空間  :using System.Linq.Dynamic;

     var dalResult = BoServiceProvider.GetBOBaseInfo(requestParams.BOTs, requestParams.Page, requestParams.Size);
            var blResult = dalResult.Select(AutoMapper.Mapper.Map<BOBaseInfo>).ToList();
            var selectFields = string.Format("new ({0})", string.Join(",", requestParams.ReturnFields));

            return await Task.FromResult(blResult.Select(selectFields));