Questions tagged [expression-trees]

Expression Trees are an abstract representation of code in a tree structure where each node of the tree represents a programming construct (conditional, assignment, method call, etc.)

2090 questions
1
vote
0 answers

Apply Expression Tree Logic Directly on Properties?

It's possible (perhaps even likely) that I'm mixing up terminology here. So let me explain the idea... Currently I have an Entity Framework 6 code-first kind of approach, with some persistence-ignorant models and some interfaces for IUnitOfWork and…
David
  • 208,112
  • 36
  • 198
  • 279
1
vote
1 answer

Build Expression tree for LINQ to Entities Where clause

I want to be able to write the following code for a LINQ to Entities query (EF6) Repo.ContactRelations.WhereActive() .Select(r => new ContactModel { Id = r.Contact.Id, FirstName…
ozstudent
  • 381
  • 1
  • 5
  • 14
1
vote
1 answer

Expression Tree throws error

In my VS LIGHTSWITCH 2013 portal application I allow the user to create tiles that link to other internal apps. When a new tile is create a Role with the name 'TileTitle + " User"' is created. This way I can show and hide tiles based on a users…
1
vote
1 answer

How to build an anonymous object with expression trees

I have a class public class SomeClass { public int num { get; set; } public string str{ get; set; } } I need to construct a lambda expression like: (x => new {new_num= x.num, new_str= x.str}) Properties are listed in some enumerable object…
Serg Tomcat
  • 812
  • 10
  • 21
1
vote
1 answer

Linq Expression from Lambda: specify parameter explicitly

I want to embed an expression tree such as Expression> expr = (o) => o.Value; into a larger expression tree generated by a parser. However, the parameter o is already defined inside the outer expression tree. In principle I…
LionAM
  • 1,271
  • 10
  • 28
1
vote
0 answers

SqlFunctions.StringConvert in Expression Tree

I'm attempting to write an expression tree which supports dynamic use of StartsWith on number values. The idea is to use this method to build dynamic where queries, based on a user input, and execeute them against EF 6. I’ve already written a…
musium
  • 2,942
  • 3
  • 34
  • 67
1
vote
1 answer

Getting MemberExpression, expecting ConstantExpression

Many problems today! I can't figure this out so I thought I'd throw it out there. I am writing a fluent interface to build an SQL string (yes I know about LINQ to Entities...it's a long story). I am checking the type of expression in an if/else…
serlingpa
  • 12,024
  • 24
  • 80
  • 130
1
vote
0 answers

Failing to get a strong name from an Expression

It's probably best I explain with an example. I am writing a fluent interface, which includes a Where method: public FluentSearch Where(Expression> expression) which I might call like this: .Where(j => j.Driver.Chatiness ==…
serlingpa
  • 12,024
  • 24
  • 80
  • 130
1
vote
0 answers

Practical Solution for using ExpressionTree in WCF projects

I want to use Expresstion Trees in WCF Projects public interface IService1 { [OperationContract(Name = "GetByPredicate")] List Get(Expression> expression); [OperationContract] List Get(); } but…
Hamed F
  • 800
  • 3
  • 11
  • 23
1
vote
0 answers

Could not find a matching type in ExpressionSerialization.dll

I use ExpressionSerialization library for serializing Expression Tree but get me an error Could not find a matching type WCF Service : public class Person { public int ID { get; set; } public string Name { get; set;…
Hamed F
  • 800
  • 3
  • 11
  • 23
1
vote
1 answer

Get MemberAssignments from Action

I'm trying to build a method that can capture assignments from a strongly-typed statement body. The method call should look something like this: myObject.Assign(o => { o.SomeProperty = 1; …
Sören Kuklau
  • 19,454
  • 7
  • 52
  • 86
1
vote
1 answer

Expression Tree ToString() method generates strange string WHY?

I need string conversion of an Expression Tree so I create an Expression Tree and use ToString method like this var exp = ((Expression>) (x => x.OperationID == operationId)).ToString(); but result is strange x =>…
Hamed F
  • 800
  • 3
  • 11
  • 23
1
vote
0 answers

Serialize.Linq does not work in WCF proxy layer

I use Serialize.Linq for send and receive Expression> query between Client and Server in WCF Application service because Expression> can not be serialized all things seems ok BUT when I add reference this library to wcf proxy layer and…
Hamed F
  • 800
  • 3
  • 11
  • 23
1
vote
1 answer

DLINQ projecting into concrete types with expression trees

I have an expression tree for Purchase class public static readonly Expression> CurrentPaidSumLambda = p => (double?)p.Payments .Where(pa => pa.Status == SystemConstants.PaymentStatus.Paid) .Sum(pa => pa.Sum); I wish…
alex440
  • 1,647
  • 3
  • 20
  • 35
1
vote
2 answers

How can I convert Linq to Entities Query into expression tree?

Say I have the following query how can I get the base Expression Tree? MyContext.Items.Select(i=>i.Color); I want to get the expression tree of this so that I can then use the expression tree to dynamically set what property is being selected (So…
user2125348
  • 430
  • 1
  • 7
  • 21