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
5 answers

What is the difference between 'Data Structure' and 'compiled code'

Expression trees purpose: Expression tree must be compiled before it can be used. This is because expression tree is actually a data structure, not compiled code. Why? Because this code is expected to be used across wire, or – in other words – in…
Stav Alfi
  • 13,139
  • 23
  • 99
  • 171
1
vote
1 answer

Inline delegate for Linq to Entities

I have a feeling I already know the answer to this question. I have an expression that common but complex, and I would like to re-use the code in multiple locations. I would like to use a function that returns a Func with some code: public static…
object88
  • 720
  • 1
  • 7
  • 20
1
vote
1 answer

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 =…
Morten Holmgaard
  • 7,484
  • 8
  • 63
  • 85
1
vote
2 answers

Expression tree, how do I switch over the returned data type (string, int, float)

I am rewriting an existing template solution with scripting support to run as an expression tree instead of interpreting the AST every execution and the logic has to work with existing scripts. What I am trying to achieve right now is to create a…
David Mårtensson
  • 7,550
  • 4
  • 31
  • 47
1
vote
2 answers

Help parsing my own expression tree, C#

I have the following code. I constructed an expression tree and I am stuck parsing it to find the result You will find the details within my code public enum OpertaionType { add, sub, div, mul} public class Node { public Node(Node lhs, Node…
mustafabar
  • 2,317
  • 6
  • 31
  • 47
1
vote
1 answer

Improve string.Format CallExpression

I am trying to call string.Format using Tree It took me a bit of work since my supply params Expression[] _ParameterExpressions does not match signature of string.Format which accept object[] it seems it won't apply implicit conversion. My current…
ipoppo
  • 369
  • 2
  • 11
1
vote
1 answer

C# Expression.Lambda cannot be compiled at runtime

I have build expression parser CreateExpression() which return constructed Expression Tree Expression rule = CreateExpression(_BuyRuleString); LambdaExpression lambda = Expression.Lambda(rule, _ParameterExpressions); var func =…
ipoppo
  • 369
  • 2
  • 11
1
vote
1 answer

Combine SQL with XQuery and Linq To SQL

How to efficiently combine a direct SQL query and Linq To SQL query? Linq To SQL doesn't support XQuery. So I have to combine the results of a SQL with XQuery and column based Linq To SQL? Any pointers is appreciated. Thanks!
Sam
  • 933
  • 5
  • 14
  • 26
1
vote
0 answers

Is the Expression.* namespace the only way to create expression trees for EF 4.3 + ODAC?

I am having an issue with ODAC (Oracle Data Access Components), Entity Framework 4.3.1, and expression trees. We have a legacy database (don't we all?) that we are mapping in Entity Framework. The table has millions of records and over one hundred…
1
vote
0 answers

Teaching entity framework generating SQL for custom NodeTypes

Is it possible to customize generation of SQL by using custom Expression inheritors with NodeType Extension and CanReduce = false? Consider the following gist where Name is a property in the ViewModel and Attribute1 is an attribute in SQL-typed…
kerem
  • 2,699
  • 1
  • 32
  • 37
1
vote
1 answer

Cast function expression tree from object

I've ended up with a situation where an function expression tree Expression> is assigned to a global variable of type object and then later in the code I need to call a different method with the expression. I can't change the…
Chris Moutray
  • 18,029
  • 7
  • 45
  • 66
1
vote
2 answers

How to create a custom HTML Helper method DropDownFor in ASP.Net MVC

I'm trying to create a dropdown box that will render a label under certain conditions when teh user does not have access to it. so far I have come up with this public static MvcHtmlString ReadOnlyCapableDropDownFor( this…
Daniel Powell
  • 8,143
  • 11
  • 61
  • 108
1
vote
0 answers

binary expression

I would like to build a LINQ query from string parameters. I have a grid in Silverlight and I want to filter a result of query by columns. When the users click on a button on one of the grid columns a listview will be displayed. They select one or…
user295541
  • 1,015
  • 4
  • 16
  • 26
1
vote
1 answer

EF dynamic projection (mapping to the Dictionary of property-value pair)

I'm trying to implement dynamic projection for Entity Framework to be able to specify list of properties to return ang get a dictionary of values as a result. public static IQueryable> ProjectionMap
1
vote
1 answer

How to build expressions for reflected properties

I've built an MVC Html helper with this signature: public static MvcHtmlString EditFieldFor(this HtmlHelper html, Expression> expression, object additionalViewData = null) I'm trying to build another…
Ronnie Overby
  • 45,287
  • 73
  • 267
  • 346
1 2 3
99
100