Get Argument Values From Linq Expression

If you even find yourself unpacking an expression in C#, you might find this useful. I found myself in need of obtaining a list of argument values from within an Expression<func> expression that sometimes had chained method calls. For example, I needed to be able to get the arguments from all of the following…

SomeMethod(() => getInformation.ForCustomer(CustomerId));

SomeMethod(() => MyFactory.GetInformation().ForCustomer(CustomerId));

SomeMethod(() => MyFactory.GetInformation().ForCustomer(CustomerId).ToList());

In the end, I created a couple of extension methods to help. One converts an expression into a MethodCallExpression (if that is a valid conversion), which is a type that has arguments. The second recursively searches for the arguments.

Get Argument Values From Linq Expression的更多相关文章

  1. [Linq Expression]练习自己写绑定

    源代码:TypeMapper.zip 背景 项目中,我们会经常用到各种赋值语句,比如把模型的属性赋值给UI,把视图模型的属性拷贝给Entity.如果模型属性太多,赋值也会变成苦力活.所以,框架编程的思 ...

  2. ling join 报错The specified LINQ expression contains references to queries that are associated with different cont

    The specified LINQ expression contains references to queries that are associated with different cont ...

  3. C# ORM中Dto Linq Expression 和 数据库Model Linq Expression之间的转换

    今天在百度知道中看到一个问题,研究了一会便回答了: http://zhidao.baidu.com/question/920461189016484459.html 如何使dto linq 表达式转换 ...

  4. diff/merge configuration in Team Foundation - common Command and Argument values - MSDN Blogs

    One of the extensibility points we have in Team Foundation V1 is that you can configure any other di ...

  5. C# [LINQ] Linq Expression 获取多格式文件

    using System; using System.IO; using System.Linq; using System.Linq.Expressions; internal static str ...

  6. 查看LINQ Expression編譯後的SQL語法(转)

    在用了LINQ語法之後的一個月,我幾乎把SQL語法全部拋到腦後了,不過 LINQ好用歸好用,但是實際上操作資料庫的還是SQL語法,如果不知道LINQ語法 編譯過後產生怎樣的SQL語法,一不小心效能就會 ...

  7. The specified LINQ expression contains references to queries that are associated with different contexts

    今天在改写架构的时候,遇到这么个错误.当时单从字面意思,看上去错误是由join的两个不同的表来源不一致引起的. 其中的videoResult和deerpenList均来自与同一个edmx文件,所以两个 ...

  8. Expression 表达式动态生成

    http://blog.csdn.net/duan1311/article/details/51769119 以上是拼装和调用GroupBy的方法,是不是很简单,只要传入分组列与合计列就OK了! 下面 ...

  9. Expression Tree Basics 表达式树原理

    variable point to code variable expression tree data structure lamda expression anonymous function 原 ...

随机推荐

  1. Android利用系统原生BottomNavigationView实现底部导航

    <android.support.design.widget.BottomNavigationView android:id="@+id/navigation" androi ...

  2. win10 下的YOLO v3 的编译与使用

    部署环境:win10 +CUDA 10.0 + vs2017 + opencv 3.4.0  代码版本是 https://github.com/AlexeyAB/darknet 1.初始准备 (1)下 ...

  3. python之random、time与sys模块

     一.random模块 import random # float型 print(random.random()) #取0-1之间的随机小数 print(random.uniform(n,m)) #取 ...

  4. Python统计字符出现次数(Counter包)以及txt文件写入

    # -*- coding: utf-8 -*- #spyder (python 3.7) 1. 统计字符(可以在jieba分词之后使用) from collections import Counter ...

  5. AD19新功能之跟随走线

    跟随走线 AD19新增跟随走线,比如需要按照特定的轨迹进行走线,比如要绕着一个圆进行走线,或者靠着边框走线,普通模式下的效果如下图所示,线会跟着指针跑: 在走线模式下,按住 shift + f ,然后 ...

  6. Redis未授权访问漏洞复现及修复方案

    首先,第一个复现Redis未授权访问这个漏洞是有原因的,在 2019-07-24 的某一天,我同学的服务器突然特别卡,卡到连不上的那种,通过 top,free,netstat 等命令查看后发现,CPU ...

  7. 基于Java+Selenium的WebUI自动化测试框架(三)------记录LOG

    在有了Position类和接口类之后,我们是不是立刻就要着手开始写实现类了呢?按照一般的顺序是这样.但是,我们这里先停一下.原因有二: 1)既然是写一个框架,我们希望总体的功能上是全面的.实现类中,我 ...

  8. 7月新的开始 - Axure学习03 - 布尔运算、表单元件

    布尔运算 布尔运算:是一种数字符号化的逻辑推演法.包含联合.相交.相减等 在图形处理中,通过联合.相交.相减等操作使基本的图形组合产生新的形体 操作 准备 蓝色(底部).绿色(顶部) 合并:两个图形合 ...

  9. AtCoder Beginner Contest 143 F - Distinct Numbers

    题意 给出一个长度为NNN的序列,求对于所有k∈[1,N]k\in[1,N]k∈[1,N],每次从序列中选出kkk个互不相同的数,最多能取多少次. N≤3e5N\le3e5N≤3e5 题解 我们首先把 ...

  10. TDOA 之 基站接收数据

    基站主要 接收同步节点发来的同步信号,代码里定义为S信息. 以及标签节点发来的定位信号,代码中定义为T信号. 代码中使用中断以及帧过滤功能,对模块只接收自己关心设定好的信息,通过中断告知上层,而不是长 ...