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

Expression Tree Tutorial - Knowledge Base (KB)

115 results in tag: .net

In C#, how can I represent 'String.Contains("term")' with an expression tree?

I am just getting started with expression trees so I hope this makes sense. I am trying to create an expression tree to represent:...t => t.SomeProperty.Contains("stringValue"); ...So far I have got:... private static Expression.Lambda<Func<string, boo...
.net c# expression-trees lambda
asked by flesh

Within a generic extension method, how do I apply OrderBy to an IQueryable using a string column name?

public static IQueryable<TResult> ApplySortFilter<T, TResult>(this IQueryable<T> query, string columnName) where T : EntityObject { var param = Expression.Parameter(typeof(T), "o"); var body = Expression.PropertyOrField(param,columnName); var sor...
.net c# entity-framework expression-trees linq
asked by JTew

I'm not sure how to make an expression tree using IEnumerableTSource>. Any(...)?

I am trying to create an expression tree that represents the following:...myObject.childObjectCollection.Any(i => i.Name == "name"); ...Shortened for clarity, I have the following:...//'myObject.childObjectCollection' is represented here by 'propertyExp' ...
.net c# expression-trees linq
asked by flesh

In C#, how can I build an Expression Tree by parsing XML?

I am looking to create an expression tree by parsing xml using C#. The xml would be like the following:...<Expression> <If> <Condition> <GreaterThan> <X> <Y> </GreaterThan> </Condition> <Expression /> <If> <Else> <Expression />...
.net c# expression-trees linq xml
asked by SharePoint Newbie

What is the best way to integrate two Member Expression Trees?

I'm trying to combine the following expressions into a single expression: item => item.sub, sub => sub.key to become item => item.sub.key. I need to do this so I can create an OrderBy method which takes the item selector separately to the key selector. Th...
.net c# expression-trees lambda linq-to-sql
asked by LaserJesus

Dummies' expression trees?

I am the dummy in this scenario....I've tried to read on Google what these are but I just don't get it. Can someone give me a simple explanation of what they are and why they're useful?...edit: I'm talking about the LINQ feature in .Net.
.net c# expression-trees linq
asked by Dave

Linq to SQL query compilation from a non-trivial IQueryable

Is there a way to use the CompiledQuery.Compile method to compile the Expression associated with an IQueryable? Currently I have an IQueryable with a very large Expression tree behind it. The IQueryable was built up using several methods which each supply...
.net expression-trees linq-to-sql performance
asked by LaserJesus

How may the type of a parameter in an expression be changed?

since i am using POCOS in my domain, i want my repository to be able to received Expression filters of the type of my POCOS and change the parameter in the expression to be the of type of my LINQ tables, my fields have the same name as my members so i was...
.net c#-3.0 expression-trees lambda linq
asked by Oscar Cabrero

Is there a simple method to convert a string (lambda expression) into an Action delegate?

I have a method that alters an "Account" object based on the action delegate passed into it:...public static void AlterAccount(string AccountID, Action<Account> AccountAction) { Account someAccount = accountRepository.GetAccount(AccountID); AccountAct...
.net c# expression-trees linq parsing
asked by Whisk

How do you break down an equation into separate variable formulas?

How to convert an equation into formulas for individual variables? I am thinking about a math equations like:...c^2 = a^2 + b^2 ...I would like to have a function that could process any formula, and give me the individual variable formulas. The above equ...
.net c# expression-trees logic math
asked by Bobby Ortiz

How can I parse random strings into expression trees in C#?

In a project that I'm working on I have to work with a rather weird data source. I can give it a "query" and it will return me a DataTable. But the query is not a traditional string. It's more like... a set of method calls that define the criteria that I ...
.net c# expression-trees parsing
asked by Vilx-

What is a decent use case for Expression Trees in.net 4.0?

This one was inspired by my language-guru co-worker who can't seem to find a good use for them, and after a few lame attempts of my own, I'd have to agree. ...Now I know these concepts tend to flow a lot more easily once you get some good practical reason...
.net expression-trees linq
asked by KevinDeus

Trees of expressions/statements

Updated Question Further Down...I've been experimenting with expression trees in .NET 4 to generate code at runtime and I've been trying to implement the ...foreach... statement by building an expression tree. ...In the end, the expression should be able ...
.net c# expression-trees
asked by JulianR

What is the purpose of Expression.Reduce()?

I've been working with expression trees for a few days now and I'm curious to know what Expression.Reduce() does. The ...msdn documentation... is not very helpful as it only states that it "reduces" the expression. Just in case, I tried an example (see be...
.net c# expression-trees lambda
asked by d..

Invoking a Delegate and Expression Trees

So I have a ...delegate... which points to some function which I don't actually know about when I first create the ...delegate... object. The object is set to some function later....I also then want to make an expression tree that invokes the delegate wit...
.net c# delegates expression-trees lambda
asked by PythonPower

Create a new expression from an existing one

I have an ...Expression<Func<T,DateTime>>... I want to take the DateTime part of the expression and pull the Month off of it. So I would be turning it into a ...Expression<Func<T,int>>... I'm not really sure how to do this. I looked at the ...ExpressionTr...
.net c# expression expression-trees lambda
asked by Adam

An argument exception occurs while using an Expression Tree with Property Inheritance.

Following this post: ...link text... I'm trying to create an expression tree that references the property of a property. My code looks like this:...public interface IFoo { void X {get;set;} } public interface IBar : IFoo { void Y {get;set;} } pu...
.net expression-trees linq
asked by Adam Driscoll

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

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

Page 1 of 6
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • ยป

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!