开发者

.net-Linq the use of Expression<T>

开发者 https://www.devze.com 2023-02-09 21:01 出处:网络
Can you开发者_开发问答 Explain the terms Expression Tree... Expression in Linq ?I\'d recommend reading up on Expression Trees on MSDN.

Can you开发者_开发问答 Explain the terms Expression Tree... Expression in Linq ?


I'd recommend reading up on Expression Trees on MSDN.

They're most commonly used with LINQ when using IQueryable<T>, ie: LINQ to Sql or Entity Framework and similar. The lambda expression you pass to a LINQ query gets turned into an expression tree, which is a way to "represent code in a tree-like data structure".

This allows the provider in question to turn this into an actual SQL database call, since it can parse the expression tree and translate it into something the database understands natively.

That being said, this can be used in other places, as well. Any time you need to represent "code" and build it up, you can use expression trees. For example, this is often used to implement INotifyPropertyChanged without requiring strings to be passed.

0

精彩评论

暂无评论...
验证码 换一张
取 消