zzz projects Expression Tree Tutorial
Getting Started Documentation Knowledge Base
  • Getting Started
  • Documentation
  • Knowledge Base

Expression Tree Tutorial - Knowledge Base (KB)

656 results

The value of a member expression may be accessed.

If i have a product....var p = new Product { Price = 30 }; ...and i have the following linq query....var q = repo.Products().Where(x=>x.Price == p.Price).ToList() ...In an IQueryable provider, I get a MemberExpression back for the p.Price which contains a...
c# expression-trees lambda linq
asked by Schotime

NotifyProperty (typesafe) Using linq expressions, it was changed.

Form ...Build your own MVVM... I have the following code that lets us have typesafe NotifyOfPropertyChange calls:...public void NotifyOfPropertyChange<TProperty>(Expression<Func<TProperty>> property) { var lambda = (LambdaExpression)property; Memb...
expression-trees inotifypropertychanged mvvm wpf
asked by bitbonk

In the Select() query, a lambda expression will be utilized.

I am trying to build a lambda expression, containing two assignments (as shown further down), that I can then pass to a Queryable.Select() method. ...I am trying to pass a string variable into a method and then use that variable to build up the lambda exp...
c# expression-trees lambda
asked by jameschinnock

Changing a predicate's expression tree to target a different type

Intro...In the application I 'm currently working on, there are two kinds of each business object: the "ActiveRecord" kind and the "DataContract" kind. So for example, there would be:...namespace ActiveRecord { class Widget { public int Id { g...
c# expression-trees lambda linq
asked by Jon

With the expression argument, call the asp.net mvc Html Helper from inside a custom html helper.

I am trying to write an html helper extension within the asp.net mvc framework....public static MvcHtmlString PlatformNumericTextBoxFor<TModel>(this HtmlHelper instance, TModel model, Expression<Func<TModel,double>> selector) where TModel : TableS...
asp.net-mvc expression-trees html-helper lambda
asked by Frank Michael Kraft

expression tree to sql statement

I'm wondering how one would translate a sql string to an expression tree. Currently, in Linq to SQL, the expression tree is translated to a sql statement. How does on go the other way? How would you translate ...select * from books where bookname like ...
c# expression-trees
asked by Joo Park

Using Lambda Expressions to Call a Generic Method (and a Type only known at runtime)

You can use ...Lambda Expression Objects... to represent a lambda as an expression....How do you create a ...Lambda Expression Object... representing a generic method call, if you only know the type -that you use for the generic method signature- at runt...
c# expression expression-trees generics lambda
asked by SDReyes

What are some LINQ expressions that use MemberBinding?

There are three possibilities, but I can't find examples:...System.Linq.Expressions.MemberAssignment...System.Linq.Expressions.MemberListBinding...System.Linq.Expressions.MemberMemberBinding...I want to write some unit tests to see if I can handle them, b...
.net c# expression-trees linq
asked by Michiel van Oosterhout

expressive tree-based dynamic query

I have a form in which the user will choose the following from dropdown lists:... table_name columnName_to_sort_by columnName_to_search_in ...The user shall enter ...Search_text... in a text box...The form shall draw data from many tables. I want to ...
c# dynamic-linq expression-trees
asked by user375492

What is the purpose of ExpressionVisitor.VisitT>?

Before someone shouts out the answer, please read the question through....What is the purpose of the method in .NET 4.0's ExpressionVisitor:...public static ReadOnlyCollection<T> Visit<T>(ReadOnlyCollection<T> nodes, Func<T, T> elementVisitor) ...My first...
c#-4.0 expression-trees expressionvisitor linq
asked by Jeff

How to evaluate a prefix notation expression

I am trying to evaluate a list that represents an expression in prefix notation. Here is an example of such a list:...[+, [sin, 3], [- 10 5]] ...What is the best way to evaluate the value of the list
evaluation expression-trees s-expression
asked by ad126

Expression trees vs. CodeDom in C# 4.0

What are the differences between Expression trees and CodeDom? Which should I use for which scenario?
c# codedom expression-trees
asked by Yaron Naveh

Creating a method-calling expression tree

Is it possible to create an expression tree that directly calls a method? For example, consider the following method:...public static int MyFunc(int a, int b) { return a + b; } ...I would like to create an expression tree that calls MyFunc with parame...
c# delegates expression-trees lambda reflection
asked by brianberns

How to obtain variables in scope while creating a LINQ expression tree

I'm building a LINQ expression tree but it won't compile because allegedly the local variable ...$var1... is out of scope:...variable '' of type 'System.Object' referenced from scope '', but it is not defined...This is the expression tree:....Block() { ...
.net c# expression-trees lambda linq
asked by Sandor Drieënhuizen

In this expression tree, why am I getting a null reference exception?

I have a tree expression that looks like this:....Block( System.Object $instance, MyType2 $result) { $result = (MyType2)((MyType1)$instance).Property1; .Goto return { }; .Label .LabelTarget useDefault:; $result = .Default(MyTyp...
.net c# c#-4.0 expression-trees lambda
asked by Sandor Drieënhuizen

Local Evaluation of Linq Func/Expression

Given this code:... int min = 0; Expression<Func<List<IUser>, bool>> ulContainsJohn = (l => l.Where(u => u.FirstName == "John").Count() > min); Assert.AreEqual(true, ulContainsJohn.Compile()(userList)); ...
expression-trees linq
asked by Shlomo

Create a completely dynamic where clause using an expression tree and run it via IQueryable.

At point (3) in my code I have defined a query called query1 in which I defined a .Where lambda expression. This query is in some way dynamic but still contains static elements, it always refers to the Type Employee and its (int) property ClientID. ...Now...
c# expression-trees iqueryable lambda where
asked by Wouter Vegter

Using an Expression Tree to Combine Expressions

How can I build an expression tree when parts of the expression are passed as arguments?...E.g. what if I wanted to create expression trees like these:...IQueryable<LxUser> test1(IQueryable<LxUser> query, string foo, string bar) { query=query.Where(x =>...
c# expression-trees lambda
asked by laktak

LINQ Querying an Entity with Dynamic Field Names

I have created a dynamic search screen in ASP.NET MVC. I retrieved the field names from the entity through reflection so that I could allow the user to choose which fields they wanted to search on instead of displaying all fields in the view....When the ...
c# dynamic-linq expression-trees lambda linq-to-entities
asked by Scott Lance

In C#, use reflection to convert a function to a predicate.

I'm basically trying to do ...this..., but I don't know what T will be, so I'm building things up using Reflection and Expression trees....// Input (I don't know about "Book") Type itemType = typeof(Book); // Actual Code // Build up func p => p.AuthorNam...
c# expression-trees predicate reflection
asked by Jon Smock

Page 5 of 33
  • «
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • …
  • »
  • »»

Prime Library

Performance

  • Entity Framework Extensions
  • Entity Framework Classic
  • Bulk Operations
  • Dapper Plus

Expression Evaluator

  • C# Eval Expression
  • SQL Eval Function
More Projects...
Get monthly updates by subscribing to our newsletter!
SUBSCRIBE!