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

Expression Tree Tutorial - Knowledge Base (KB)

656 results

Using a Linq Expression tree, find an event.

The compiler usually chokes when an event doesn't appear beside a ...+=... or a ...-=..., so I'm not sure if this is possible....I want to be able to identify an event by using an Expression tree, so I can create an event watcher for a test. The syntax wo...
c# expression-trees linq
asked by user1228

Without distinct try-catch blocks, try-catch every line of code.

I do not currently have this issue..., but you never know, and thought experiments are always fun....Ignoring the obvious problems that you would have to have with your architecture to even be attempting this..., let's assume that you had some horribly-wr...
c# expression-trees try-catch
asked by tags2k

C# Expression Trees Advice

I'm working on a method that accepts an expression tree as a parameter, along with a type (or instance) of a class....The basic idea is that this method will add certain things to a collection that will be used for validation....public interface ITestInte...
c# expression-trees reflection
asked by Ian P

In.NET 3.5 expression trees, assignment

Is it possible to encode an assignment into an expression tree?
expression-trees linq
asked by Eric Smith

Expression Trees in C#: Serializing and Deserializing

Is there a way to Deserialize Expressions in C#, I would like to store Expressions in a Database and load them at run time.
c# expression-trees serialization
asked by Alexandre Brisebois

What is the best way to create a Linq Expression Tree that compares to a generic object?

I have an IQueryable and an object of type T....I want to do IQueryable().Where(o => o.GetProperty(fieldName) == objectOfTypeT.GetProperty(fieldName))...so ......public IQueryable<T> DoWork<T>(string fieldName) where T : EntityObject { ... T...
c# entity-framework expression-trees generics linq
asked by JTew

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

How can I retrieve the field value for a type ExpressionType.MemberAccess?

I am parsing an Expression Tree. Given a NodeType of ExpressionType.MemberAccess, how do I get the value of that Field? ...From C# MSDN docs: MemberAccess is A node that represents reading from a field or property. ...A code snippet would be incredibly, ...
c# expression-trees reflection
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

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

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

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

In Expression Trees, what is the best technique to invoke an instance method?

What is the best way to call an instance method within an Expression Tree? My current solution is something like this for an interface method "object GetRowValue(rowIndex)" of the interface IColumn....public static Expression CreateGetRowValueExpression( ...
c# expression-trees linq
asked by Rauhotz

The use of expression trees

Expression trees are a nice feature, but what are its practical uses? Can they be used for some sort of code generation or metaprogramming or some such?
c# expression-trees
asked by Dmitri Nesteruk

Expression. Alternatively, the argument 'item' is out of scope.

I am trying to write a static function to Or two expressions, but recieve the following error:...The parameter 'item' is not in scope....Description: An unhandled exception occurred during the execution of the current web request. Please review the ...
c# expression expression-trees linq
asked by ccook

How do you feed bits of a LINQ query into a function in LINQ to SQL?

Is it possible to pass parts of a linq Query into a function? I want create a common interface for my DAL that always uses the same query interface. For example, ...List<T> Get(Join j, Where w, Select s){ return currentDataContext<T>.Join(j).Wh...
c# expression-trees linq linq-to-sql
asked by Arron S

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

Page 1 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!