Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.)

1
vote
0answers
59 views

Extension “With” for immutable types

(My code is basically a rewrite of https://github.com/ababik/Remute so much of the credit goes there) The idea is to use lambda expression to provide a general With...
2
votes
0answers
33 views

Quiz for random boolean expressions

Inspired by the various quiz programs on this site, as well as Simon Tatham's puzzle collection, I thought I'd write a quiz that constructs its questions automatically and randomly. A typical session ...
6
votes
1answer
192 views

Adjusting business logic conveniently through JSON and expression trees

I need to evaluate some data. The rules how it should be done are changing frequently (it's an evolving model) so I don't want to rewrite my application each time such a change comes. I'd rather do it ...
4
votes
0answers
61 views

Dynamic setting names based on properties

In one of my frameworks that I use with many tools I have an ExpressionVisitor whose job is to resolve the exact property, it's declaring type and instance. I ...
1
vote
1answer
142 views

Expression tree in Haskell with support for differentiation

A simple binary expression tree in Haskell without operator precedence and without parentheses. Any comments would be much appreciated. ...
14
votes
3answers
402 views

Building unusual IComparer<T> from expressions

I've needed a couple of very special comparers recenty and didn't want to implement each one of them every time so I created a builder and a couple of supporting classes that do that for me. Example ...
9
votes
4answers
556 views

Selective updates to immutable types

There is a way in Scala to selectively change a field while making a copy of the immutable object: ...
5
votes
1answer
171 views

Inserting into a binary expression tree with GOTO

I'm working on a binary space partition tree. For the time being, the nodes are only inserted into the right. A node that has children will have 0 as data. Here are the insertion rules. If the ...
13
votes
3answers
675 views

Building DebuggerDisplay strings

The DebuggerDisplayAttribute is a very helpful feature. But creating those strings is an extremely tedious task. I wanted to make it a no-brainer so that I can ...
2
votes
0answers
84 views

Implementing the IQueryable counterpart method of the IEnumerable method?

I have created this method to simulate SQL's IN operator: ...
9
votes
5answers
3k views

Calculate fingerprint for an object

I need to store serialized objects in a database and I want to avoid duplicates. In order to be able to tell wheter an object is already stored, I have to compare them somehow. My idea was to ...
16
votes
6answers
6k views

Simple object validator

I wrote a simple validation tool that allows me to quickly define validation rules and check my data objects against them. I know there is this another tool called FluentValidation but... I'm not a ...
7
votes
4answers
327 views

Simple generic sequence generators

I've been improving some of my old sequence generators that worked with generics and lambdas in order to support binary operators for the specified T: ...
10
votes
5answers
381 views

Declarative type comparer

Writing comparers by either implementing the IEqualityComparer<T> or the IEquatable<T> interface is another boring ...
2
votes
1answer
134 views

Unit-test helper extensions for binary operators

This time I'd like you to review my unit-test helpers for binary operators. I wrote them because I'm often to lazy to test these operators because writing those tests is so boring. My little helpers ...
8
votes
1answer
1k views

GroupBy(params string[] fields)

Linq to Object GroupBy extension method allows grouping by projection: ...
6
votes
1answer
294 views

Extensions for setting members via expressions and reflection

I'd like to make the usage of my configuration framework easier so I created a few extensions that after getting a value from a source automatically assign it to a property or field. They should make ...
2
votes
0answers
76 views

Computer Algebra System that computes symbolic derivatives

I have a system that parses a mathematical expression String, creates a derivative expression tree, and reconstructs the derived expression into a new ...
3
votes
1answer
2k views

Generating variable names and getters from member expression

I have a JSON configuration file where the user is allowed to use inside strings certain placeholders {Type.Name} that later will be interpolated with the actual ...
5
votes
1answer
157 views

Calculating user efficiency on a time period with Linq

I have this expression: ...
4
votes
1answer
691 views

Specification pattern in EF part 2

This is a follow on to Part 1 In order to use my new Specifications within expression trees so I can use them in projections/navigation collections I had to write ...
8
votes
2answers
2k views

Specification pattern in EF part 1

I've been experimenting with different ways of reusing (and naming) the expressions I use in Entity Framework. I've tried static fields with Expressions and ...
7
votes
1answer
245 views

LINQ Provider: Supporting Projections

Up until recently, my LINQ-to-Sage provider didn't support projections, so the client code had to explicitly "transfer" to LINQ-to-Objects, like this: ...
3
votes
1answer
211 views

Validation extensions

I've been working on another timesaver because I really really don't like to type all those validation ifs and exceptions over an over again. What I came up with ...
4
votes
1answer
264 views

Binary expression tree node with two possible states

I am building out a binary expression tree and shown below is an implementation of the tree's node. The node can be either a leaf or non-leaf, with leaves having ...
3
votes
1answer
1k views

Building expression tree with multiple OrElse

I am creating a way for users to filter results based on start and end values. An example of this would be: ...
10
votes
1answer
201 views

Linq-to-Sage Implementation

Following-up on my last question where I wrapped the Sage API with a familiar IRepository interface, I decided to push the abstraction a step further, and... ...
12
votes
2answers
241 views

Something like a LINQ provider

Ok, before you ask: yes, I need to do this. Sort of. I'm wrapping a 3rd-party API for data access, and I can't use an ORM, so I'm implementing this kind of thing: ...
7
votes
1answer
232 views

NullGuard for throwing more informative exceptions

This small utility class is my solution for a more convenient way for checking against null. I also wanted to have more informative NullReferenceExceptions but I ...
0
votes
1answer
383 views

Refactor Linq Expression [closed]

Is there any way I can refactor this expression tree? ...
8
votes
3answers
20k views

Generic advanced Delegate.CreateDelegate using expression trees

As far as I know the standard Delegate.CreateDelegate() which allows to create a delegate by using reflection, doesn't allow doing something as follows when the ...