Lambda select 动态字段
直接上代码
//测试数据
public static List<User> myList = new List<User>()
{
new User(){ID=, Name="部门1",Age=,IsChild=false},
new User(){ID=,Name="部门3",Age=,IsChild=true},
new User(){ID=,Name="部门3",Age=,IsChild=false},
new User(){ID=,Name="部门2",Age=,IsChild=false},
new User(){ID=,Name="部门3",Age=,IsChild=true},
new User(){ID=,Name="部门1",Age=,IsChild=true},
new User(){ID=,Name="部门2",Age=,IsChild=true},
new User(){ID=,Name="部门3",Age=,IsChild=false},
new User(){ID=,Name="部门1",Age=,IsChild=true},
new User(){ID=,Name="部门3",Age=,IsChild=false},
}; public static void Main(string[] args)
{
var q = Test(x => x.ID > , x=>new User() { ID=x.ID,Name=x.Name}).ToList(); Console.ReadLine();
} //where 条件
//result 结果
public static IEnumerable<User> Test(Func<User, bool> where,Func<User,User> result)
{
var q = myList.Where(where);
return q.Select(result); } } //假设数据库全字段类型
public class User
{
public int ID { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public bool? IsChild { get; set; } public User Clone()
{
return (User)this.MemberwiseClone();
} }
Lambda select 动态字段的更多相关文章
- 【mybatis】mybatis自定义动态字段查询,mybatis实现动态字段查询,如果某个条件为null,则不查询某个字段,否则就查询某个字段
mybatis实现动态字段查询,如果某个条件为null,则不查询某个字段,否则就查询某个字段 先看一下 怎么实现动态的自定义字段查询: 例如: 而field 就是数据表中的某一个字段 String f ...
- js对select动态添加和删除OPTION
<select id="ddlResourceType" onchange="getvalue(this)"> </select> 动态 ...
- JS对select动态添加options操作[IE&FireFox兼容]
<select id="ddlResourceType" onchange="getvalue(this)"> </select> 动态 ...
- [JavaScript]JS对select动态options操作[IE&FireFox兼容]
<select id="ddlResourceType" onchange="getvalue(this)"></select> ...
- 使用js对select动态添加和删除OPTION示例代码
动态删除select中的所有options.某一项option以及动态添加select中的项option,在IE和FireFox都能测试成功,感兴趣的朋友可以参考下,希望对大家有所帮助 <s ...
- mybatis操作动态表+动态字段+存储过程
存储过程 statementType="CALLABLE" <!-- 计算金额存储过程--> <update id="getCalcDistributo ...
- JS对select动态添加option操作 (三级联动) (搜索拼接)
以下纯属自我理解之下再东搜西查的内容~ JS对select动态添加option操作有个高大上的艺名叫多级联动:第一级改变时,第二级跟着变,第二级改变时,第三级跟着变... 本菜鸟是在工作中遇到做收货地 ...
- select * 和 select 所有字段的区别
阅读本文大概需要 1 分钟. 之前发过的文章中,关于 select * 和 select 所有字段的知识,有描述不恰当,这次重新纠正下,加深下理解. MySQL 5.1.37 表记录数 41,547, ...
- solr 通过【配置、多值字段、动态字段】来解决文本表达式查询精确到句子的问题
一.Solr Multivalue field属性positionIncrementGap理解 分类:Lucene 2014-01-22 10:39阅读(3596)评论(0) 参考:http://ro ...
随机推荐
- 2019-8-31-C#-使用汇编
title author date CreateTime categories C# 使用汇编 lindexi 2019-08-31 16:55:58 +0800 2019-2-16 8:56:5 + ...
- ftp服务的安装
ftp服务的安装 1.环境准备 2.安装服务 3.配置文件 3.1.匿名访问 把以下三个匿名上传写入开启 启动并查看服务状态: Linux客户端访问: Tips: 220表示服务正常,可以登陆:230 ...
- SQLRecoverableException: I/O Exception: Connection reset
https://stackoverflow.com/questions/6110395/sqlrecoverableexception-i-o-exception-connection-reset T ...
- Session的load和get方法区别是什么?
①如果没有找到符合条件的记录,get方法返回null值,而load方法会抛出异常: ②get方法直接返回实体类对象,load方法返回实体类对象的代理: ③在Hibernate3之前,get方法只在一级 ...
- jvm主要组成部分及其作用
1.类加载器(Class Loader):加载类文件到内存.Class loader只管加载,只要符合文件结构就加载,至于能否运行,它不负责,那是有Exectution Engine 负责的. 2.执 ...
- js对象的深度拷贝
//判断对象的类型 Array Object Function String Number ..... function getObjType(obj){ return Object.prototyp ...
- maven eclipse远程部署tomcat
pom.xml tomcat 配置信息 <properties><project.build.sourceEncoding>utf8</project.build.so ...
- FastDFSClient上传图片工具类
package cn.lijun.core.util; import org.apache.commons.io.FilenameUtils;import org.csource.common.Nam ...
- php str_shuffle()函数 语法
php str_shuffle()函数 语法 str_shuffle()函数怎么用? php str_shuffle()函数用于随机的打乱字符串中所有字符,语法是str_shuffle(string) ...
- paper 135:关于C#泛型的一些讲解
计划着要用一个月的时间把 C#语言Windows程序设计 搞定,现在是零零散散的知识点,日积月累吧!朋友们,看这里咯~呵呵 原文地址:http://www.blogjava.net/Jack2007 ...