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

Expression Tree Tutorial - Knowledge Base (KB)

45 results in tag: reflection

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

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

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

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

Why are expression trees considered to be more secure than reflection?

In ...this... answer to the question of the fastest way to determine if a property contains a given attribute, user ...Darin Dimitrov... posited that expression trees are safer than reflection. Is this true, and if so, why is it true?
.net expression-trees reflection
asked by Charles Y.

How can I generate an expression tree for a query by reflecting over T?

I'm trying to build a generic class to work with entities from EF. This class talks to repositories, but it's this class that creates the expressions sent to the repositories. Anyway, I'm just trying to implement one virtual method that will act as a base...
c# entity-framework expression-trees linq reflection
asked by Gup3rSuR4c

How do I replace enumerations with ints in query expressions?

Inspired by a desire to be able to use enumerations in EF queries, I'm considering adding an ExpressionVisitor to my repositories that will take incoming criteria/specifications criteria and rewrite them to use the corresponding persisted int property....
c# entity-framework entity-framework-4.1 expression-trees reflection
asked by Morten Mertner

What is the difference between ExpressionFuncT, bool>> and ExpressionFuncType, bool>>?

I am trying build a dictionary of Expressions that have different input parameter types. I am trying to store the type of the parameter because later down the road I plan to use Reflection to discover a method on the type. Here is the code that creates th...
expression-trees functional-programming generics linq reflection
asked by Rockdocta

String.IndexOf method expression tree

How should I construct Expression tree for ...string.IndexOf("substring", StringComparison.OrdinalIgnoreCase)...?...I can get it working without the second argument: ...StringComparison.OrdinalIgnoreCase.... These are my attempts so far:...var methodCall ...
c# expression-trees linq-expressions reflection
asked by ashokgelal

Get the real return type from an instance of ExpressionFuncT, object>>.

I have a method that accepts a ...Expression<Func<T, object>>... instance. I want to get at the ...actual... data type being returned by a specific expression instance, rather than ...object.......I can get it to work for direct property references, so if...
c# expression-trees reflection
asked by Seth Petry-Johnson

Expressions use an argument to call the constructor and set its value.

i am trying to call an parameterized constructor from an expression instead of using the default ctor. this is the code that gets the constructor parameter(s):...ConstructorInfo ci = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public, null, C...
c# constructor expression-trees lambda reflection
asked by user1052087

How can I get the name of a method from an expression tree?

I am trying to implement the following pattern function:...MethodInfo GetMethod( Expression<Func<TTarget, EventHandler<TEventArgs>>> method) ...I can provide an instance of TTarget if required...The desired usage is:...public static void Main(stri...
.net c# expression-trees linq reflection
asked by Shimmy

How to use Reflection to call a non-generic static extension method with arguments.

I am using the code below to execute methods. It works for standard methods of ...string... , for example ...StartsWith..., however I am attempting to use several string extension methods, including an override for ...Contains... which alllows for case-in...
c# expression-trees reflection
asked by Rory McCrossan

Name and Value of PropertyInfo

I have seen various ways of doing this including reflection, component model type descriptors, expression trees, and aspects, BUT I'm still not sure whether the code below achieves all of the following objectives using .Net 4.0 or higher:...Be type safe, ...
c# dynamic expression-trees reflection typedescriptor
asked by Berryl

Delegate is created using the constructor.

Using reflection, I'm trying to create a delegate from a parameterless constructor like this:...Delegate del = GetMethodInfo( () => System.Activator.CreateInstance( type ) ).CreateDelegate( delType ); static MethodInfo GetMethodInfo( Expression<Func<obje...
.net-4.5 c# expression-trees reflection
asked by HappyNomad

How to set properties and nested property's properties with expression

I googled the propblem and also search the SO. There is a ton of solutions that all of them (that I found) are not completed. Can you help me please, to set a class's properties and its nested property's properties, choosen by a ...lambda..., using ...Ref...
c# expression-trees lambda reflection
asked by agent47

How can I simplify Linq extension method invokation using reflection?

Background:...I have a web service that returns the rows in a table (table name supplied as a parameter) with Ids greater than a certain Id (also supplied as a parameter). We are assuming the Ids are sequential....I am using Linq to SQL for database inter...
c# expression-trees generics linq reflection
asked by Ryan Kirkman

Use Compiled Lambda expression instead of Activator.CreateInstance to initialize SoapHttpClientProtocol object

I'm working with the code that dynamically instantiates ...SoapHttpClientProtocol... object (proxy class) and uses this object to make a call to WS-Basic I Web Service. Here is the simplified version of my code:...public override object Call(Type callingO...
activator c# expression-trees linq reflection
asked by Misha Narinsky

Casting the Expression.Property result

How do I create a cast when creating an ...Expression... tree dynamically?...The problem is, I have a property of type ...string...:...public class Test { public string Id { get; set; } } ...And I want to generically create a strongly typed lambda exp...
c# expression-trees reflection
asked by Lou

Dynamic lambda select expression

I have a lambda expression tree issue that I can’t figure out. I am trying to make a dynamic linq Select statement....I have a dynamic repository created here:...private static dynamic GetRepository(Type type) { dynamic repository = typeof(IFactory)...
.net c# expression-trees lambda reflection
asked by Morten Holmgaard

Page 1 of 3
  • 1
  • 2
  • 3
  • »

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!