54 questions
2
votes
1
answer
112
views
Implementing a LINQ Expression Visitor to Remove Pagination
I am trying to implement a LINQ Expression Visitor ([ExpressionVisitor][1]) for the following scenario: remove all pagination-related calls, such as Skip, Take, OrderBy, and OrderByDescending.
What I ...
1
vote
1
answer
130
views
Expression Visitor access property on parameter representing local variable
Trying to write an ExpressionVisitor that would rewrite a query
Starting point
var contractSubjectKey = new ContractSubjectKey(subjectId, rank);
insurance = context.Set<Insurance>()
....
0
votes
1
answer
395
views
How to Translate C# Expression to Custom Nested (recursive) Class structure?
I've custom Query Class which will be used to build query with help of lambda expression like below
var query = new Query("Person").Where<Person>(p =>
(p.Name == "Maulik" &...
1
vote
0
answers
299
views
using ExpressionVisitor how to dynamically get evaluate value of expression of a ParameterExpression
I have an expression that takes an expression as one of its parameters:
I am using a ExpressionVisitor to get the values of constants see this SO post.
but if a member is a memberAccess type I want ...
3
votes
0
answers
707
views
How to modify MemberBinding expression using Expression Visitor
I am trying to modify MemberBinding expression using Expression visitor. But I am getting an error when I try to compile the modified expression which says:
'variable 'source' of type 'EFTest.Views....
1
vote
1
answer
801
views
LINQ extension method to create Where query
I am trying to create an extension method that will be usable for both LINQ-to-Object and LINQ-to-Entities for creating a functioning Where query. More will go into it eventually but to start I am ...
1
vote
1
answer
257
views
How to call a function or property in a LINQ Query Provider (ExpressionVisitor)
I am creating a LINQ Provider. And the query could look like this:
customers.Where( (f) => f.Date < DateTime.Now )
In my Query provider I Execute an ExpressionVisitor that reads the query and ...
0
votes
1
answer
453
views
Create Arithmetic Formula using ExpressionVisitor
I am trying to create a dynamic formula via entity framework lambda from the columns of a model
public class OutputModel
{
public decimal Result {get;set;}
}
public class TableTest
{
public ...
1
vote
1
answer
1k
views
Replace parameter value in Expression Tree with a complex Expression
I'm replacing a ParameterExpression with another with the following method:
public static Expression ReplaceParameter( this Expression expression,
ParameterExpression parameter, string name )
{
...
39
votes
4
answers
19k
views
Why would I want to use an ExpressionVisitor?
I know from the MSDN's article about How to: Modify Expression Trees what an ExpressionVisitor is supposed to do. It should modify expressions.
Their example is however pretty unrealistic so I was ...
14
votes
5
answers
5k
views
Replace parameter type in lambda expression
I am trying to replace the parameter type in a lambda expression from one type to another.
I have found other answers on stackoverflow i.e. this one but I have had no luck with them.
Imagine for a ...
1
vote
2
answers
202
views
Use ExpressionVisitor to change 'obj == value' to 'obj.Equals(value)'
I'm trying to compare an object with a random value, which could be an ID, and ObjectKey or even with the same object. In short, I want to compare an object with anything, not just the same type.
To ...
2
votes
2
answers
999
views
ExpressionVisitor doesn't have it's VisitMethodCall invoked
I am following an example series on MSDN for creating a LINQ Provider and have hit a wall.
I am expecting that when I write the following test that the ExpressionVisitor sub-class in the source-code ...
2
votes
2
answers
448
views
Why is the innermost exception in an expression tree not thrown?
I've been trying to create a custom ExpressionVisitor that would generate an expression that (optionaly) throws a NullReferenceException on the first null value. The DebugView of the expression looks ...
0
votes
0
answers
112
views
How Can I use ExpressionVisitor to Change expression, adding more properties?
I have a expression with two properties and, I need changing this expression at runtime to adding more items.
public class ProductViewModel
{
public int Id { get; set; }
...
0
votes
1
answer
547
views
How do you remove OrderBy expression from an ExpressionTree using a ExpressionVisitor?
The Orderby statment is not supported by the Azure Table storage linq provider I have an Expression like
.Where(t => (t.RowKey.CompareTo("U_") > 0)).OrderBy(user => user.UserName)
i'm ...
1
vote
2
answers
471
views
Parameter Replacement when the parameter is an complex object
I'm trying to create a dynamic AndAlso filter that will be used in a Where method to a LINQ-to-EF query:
query.Where(filterExpression)
where filterExpression is a compiled lambda
So far I've ...
4
votes
1
answer
2k
views
Rewrite of an Expression Tree
I have the following Expression:
.Call System.Linq.Queryable.Select(
.Constant<System.Linq.EnumerableQuery`1[System.Linq.Dynamic.Tests.Helpers.User]>(System.Linq.Dynamic.Tests.Helpers.User[]...
2
votes
1
answer
323
views
How to rewrite expression x=>!x to x=>x!=true and x=>x to x=>x==true
Asume, that we expressions like this:
someIQueryable.Where(x => x.SomeBoolProperty)
someIQueryable.Where(x => !x.SomeBoolProperty)
I need to convert (rewrite using expression visitor) ...
0
votes
1
answer
1k
views
ExpressionVisitor.Visit throws 'must be reducible node' error in Data Service Query Visitor
I've got a problem with an implementation of the repository pattern for my WCF Data Service. To sum up, I'm trying to use a repository pattern within a client application that utilizes a plugable ...
0
votes
1
answer
285
views
Transform a c# expression
I am trying to convert a c# expression. Here is an example result I am looking for. Convert:
Expression<Func<TestObj, bool>> filter = p => p.LastName == "Smith";
to this:
Expression&...
3
votes
1
answer
378
views
Resolve ParameterExpression to actual Expression
I have written a LINQ-Provider which works perfectly but with one exception. It translates LINQ-Queries to ODATA-URL standards.
If I have the following LINQ-Statement:
.Select(x => x.Name.ToLower(...
2
votes
2
answers
1k
views
ExpressionVisitor soft delete
We're having some issues implementing soft delete functionality with entity framework. The idea is to use a repository which is aware of the EF context. On the level of the repository we implemented a ...
2
votes
1
answer
1k
views
How to bind parameters in replaced expression nodes in Entity Framework on the fly
I'm trying to replace a function call like (simplified) Utility.GetString(MyEntity.SomePropertyWithRelatedEntity)=="abc" with an expression visitor into something like p => p.SubRelatedEntities....
3
votes
2
answers
746
views
Visiting IEnumerable<T> children
Here what we want to do.
We have data from the database that we need to format to make a report, including some calculation (Sum, Averages, and field to field calculation (ex : x.a / x.b)).
One of ...