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

Expression Tree Tutorial - Knowledge Base (KB)

207 results in tag: lambda

Parsing of Lambda Expression Trees

I am trying to use Lambda Expressions in a project to map to a third party query API. So, I'm parsing the Expression tree by hand....If I pass in a lambda expression like:...p => p.Title == "title" ...everything works....However, if my lambda expression l...
c# expression-trees lambda
asked by Keith Fitzgerald

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

In a C# Expression tree, how can I set a field value?

Given:...FieldInfo field = <some valid string field on type T>; ParameterExpression targetExp = Expression.Parameter(typeof(T), "target"); ParameterExpression valueExp = Expression.Parameter(typeof(string), "value"); ...How do I compile a lambda expressio...
c# expression-trees lambda
asked by TheSoftwareJedi

Where Predicate Type Arguments in C#

I have an XElement with values for mock data. ...I have an expression to query the xml:...Expression<Func<XElement, bool>> simpleXmlFunction = b => int.Parse(b.Element("FooId").Value) == 12; ...used in:...var simpleXml = xml.Elements("Foo").Where(si...
c# entity-framework expression-trees lambda
asked by blu

how to make a deep property expression tree / lambda from a string

Given a string: "Person.Address.Postcode" I want to be able to get/set this postcode property on an instance of Person. How can I do this? My idea was to split the string by "." and then iterate over the parts, looking for the property on the previous typ...
c# expression-trees lambda
asked by Andrew Bullock

Parent Navigation Property C# Expression Tree Parameter

How can I create a ParameterExpression for the parent side of a 1 to * Navigation Property?...The following works for the child entity:...var parameter = Expression.Parameter( typeof(T), // where T is the entity type GetParameterName()); // helper...
c# entity-framework expression-trees lambda
asked by blu

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

Is it feasible to combine two queryables in C# using Linq2Sql?

I have one queryable... where I have used various ...Where... and ...WhereBetween... statements to narrow the collection down to a certain set. Now ...I need to add kind of a ...Where || WhereBetween.... In other words, I can't just chain them together li...
c# expression-trees iqueryable lambda linq-to-sql
asked by Svish

How do I change an ExpressionFuncSomeType>> to an ExpressionFuncOtherType>> in C#?

I have used C# expressions before based on lamdas, but I have no experience composing them by hand. Given an ...Expression<Func<SomeType, bool>> originalPredicate..., I want to create an ...Expression<Func<OtherType, bool>> translatedPredicate.......In th...
c# expression-trees lambda linq-to-sql repository-pattern
asked by Michiel van Oosterhout

Property name retrieved from lambda expression

Is there a better way to get the Property name when passed in via a lambda expression? Here is what i currently have....eg. ...GetSortingInfo<User>(u => u.UserId); ...It worked by casting it as a memberexpression only when the property was a string. beca...
c# expression-trees lambda linq
asked by Schotime

What is the best way to study C# expression trees thoroughly?

When I first typed this question, I did so in order to find the duplicate questions, feeling sure that someone must have already asked this question. My plan was to follow those dupe links instead of posting this question. But this question has not been a...
c# c#-3.0 expression-trees lambda
asked by Charlie Flowers

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

Why would you want to use ExpressionFuncT>> instead of FuncT>?

I understand lambdas and the ...Func... and ...Action... delegates. But expressions stump me. In what circumstances would you use an ...Expression<Func<T>>... rather than a plain old ...Func<T>...?
c# delegates expression-trees lambda
asked by Richard Nagle

How can I build an ExpressionFuncMyClass, bool>> predicate dynamically?

How would I go about using an Expression Tree to dynamically create a predicate that looks something like......(p.Length== 5) && (p.SomeOtherProperty == "hello") ...So that I can stick the predicate into a lambda expression like so......q.Where(myDynamic...
c# expression-trees lambda linq
asked by Senkwe

Issues of Expression vs. Predicate

I've got a bit of a challenge where I have to create an expression tree to represent a query input by the user. Since I don't have the time to create all the possible cases of user input, I figured that expression trees would aid me in solving this....For...
.net-3.5 c# expression-trees lambda
asked by J. Steen

How do linq expression trees acquire the value of a parameter?

AddOptional<tblObject>(x =>x.Title, objectToSend.SupplementaryData); private static void AddOptional<TType>(Expression<Func<TType,string>> expr, Dictionary<string, string> dictionary) { string propertyName; string propertyValue; Expression e...
c# expression-trees lambda linq
asked by Tadeusz Wójcik

Conversion from Lambda to Expression Tree

I will keep it really simple,...How do I get expression tree out of lambda??...or from query expression ?
c# expression-trees lambda
asked by Prashant Cholachagudda

In a LINQ expression tree, how do you evaluate a solitary boolean expression?

I'm using the standard visitor pattern to iterate through a LINQ expression tree in order to generate dynamic SQL WHERE clauses....My issue is that unlike C#, you can't use a standalone boolean expression in SQL; you have to compare it to either 1 or 0...
c# expression-trees lambda linq
asked by Nathan Ridley

C# lambda expression switch

Is it possible to have a switch in a lambda expression? If not, why? Resharper displays it as an error.
c# expression-trees lambda switch-statement
asked by Toto

Expression Tree with iQueryable

Can anybody explain me how to use (1) iQueryable (2) Expression Tree in C# by providing a very basic example? Both are not correlated, instead of making two separate questions, I wish to clear my doubt in a single question....Advanced Thanks.
c# expression-trees iqueryable lambda
asked by user184805

Page 1 of 11
  • 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!