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.

最新文章

  1. js点击按钮div显示,点击div或者body和按钮,div隐藏
  2. Java Spring-Spring与Quartz整合
  3. 一个update的小故事
  4. 【leetcode】Merge Intervals
  5. Hadoop3.0新特性介绍,比Spark快10倍的Hadoop3.0新特性
  6. SharePoint 2013 Nintex Workflow 工作流帮助(六)
  7. .Net调用非托管代码数据类型不一致的问题
  8. 获取月份对应的day
  9. 博客迁到CSDN
  10. Sql server统计查询语句消耗时间
  11. android生成apk包出现Unable to add &amp;quot;XXX&amp;quot; Zip add failed问题
  12. android--解--它们的定义tabhost(动态添加的选项+用自己的主动性横向滑动标签+手势切换标签页和内容特征)
  13. bzoj:1659: [Usaco2006 Mar]Lights Out 关灯
  14. Vigen&#232;re 密码
  15. ubuntu中使用docker部署.netcore2.1
  16. .net core 2.0 Code First Fluent API配置
  17. maven项目(多模块)
  18. Laravel 5.2 错误-----ReflectionException in compiled.php line 8572: Class App\Http\Controllers\Apih5\ZhaoshangController does not exist
  19. Linux安装rz/sz,htop插件
  20. CSS 小结笔记之浮动

热门文章

  1. 【vue&amp;ts开发】Vue 3.0前的 TypeScript 最佳入门实践
  2. javascript之位置
  3. 【异常】Maxwell异常 Exception in thread &quot;main&quot; net.sf.jsqlparser.parser.TokenMgrError: Lexical error at line 1, column 596. Encountered: &lt;EOF&gt; after : &quot;&quot;
  4. Markdown 语法介绍
  5. jwt的原理以及使用
  6. react相关知识点总结
  7. Spring 整合 Quartz框架(定时任务)
  8. Linux命令的详解
  9. Vue.js-组件化前端开发新思路
  10. javax.persistence.TransactionRequiredException: Executing an update/delete query