Skip to main content
Filter by
Sorted by
Tagged with
6 votes
1 answer
191 views

I'm experimenting with C# Expression Trees and trying to understand the difference between Expression.Return and Expression.Goto. I can’t create an example where Return and Goto behave differently ...
2 votes
1 answer
112 views

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 ...
0 votes
1 answer
100 views

I have some repeated code I'd like to move to a Razor Pages code block, which contains an asp-for tag helper. That expects a ModelExpression, and I'm unsure how to pass that. @model IndexModel @{ ...
3 votes
2 answers
112 views

Given a simple type I'm testing, say interface IMyRepo { MyObj GetBy(Expression<Func<MyObj, bool> predicate); } so the standard mock setup works just fine: _repoMock.Setup(x => x.GetBy(...
0 votes
1 answer
106 views

How can I find all the entity types referenced by the Expression passed to IQueryExpressionInterceptor.QueryCompilationStarting? Where in the expression tree should I look for them? I've tried a ...
2 votes
2 answers
99 views

I want to subscribe to any event existing on a given object, where I don't know the type in advance. I'm generatig event handler at run-time using System.Linq.Expressions.Expression. The code I have (...
2 votes
1 answer
101 views

I'm not able to find the way how to compile the deserialized Expression using Serialize.Linq. The accepted answer in "Compile Expression at runtime Using Serialize.Linq" doesn't work (part 2 ...
0 votes
0 answers
23 views

Note: the answer can be in either VB.NET or C#. I have no preference for this Q&A. I'm trying to distill this rather cumbersome line: Dim oSession As Session oSession = Await Me.DbContext....
0 votes
1 answer
58 views

I want to reuse Expression instances for another Expression building like in the code below. Is it safe? Are there any pitfalls with it? using System.Linq.Expressions; class Program { static void ...
2 votes
1 answer
100 views

I have the following classes: class Source { public int Id { get; set; } public string Name { get; set; } public SourceItem Item { get; set; } } class SourceItem { public Guid Id { ...
2 votes
0 answers
61 views

I'm using the solution from this answer to form an Expression<Func<Proposal, bool>> object (where Proposal is an entity type in my app), according to the searching criteria input on a ...
0 votes
0 answers
480 views

I'm using radzen to build a filter and apply it to a view that acts as my data set. Most everything works fine however when I try to filter by DateTime I get an error Conversion failed when ...
0 votes
2 answers
124 views

I need to append methods to an existion experssion and combine them into a new resultExpression. Expression<TSource, IQueryable<TResult>> sourceExpression; Expression<TSource, int, int, ...
0 votes
1 answer
161 views

I want to pass a dynamic GroupBy expression into an IQueryable. I'm already doing something similar with a Where clause that is working OK. The purpose of the group by is then to allow my to extract ...
0 votes
3 answers
109 views

I am trying to use C# object initializer syntax with LINQ Expressions trees and I used type conversions (i.e. Expression.Convert) so I shouldn't get invalid cast exceptions for simple type conversions ...
11 votes
1 answer
1k views

I have an existing expression of type Expression<Func<T, object>>; it contains values like cust => cust.Name. I also have a parent class with a field of type T. I need a method that ...
0 votes
1 answer
524 views

I have a TPH architecture with the following hierarchy: abstract class Task { public int A { get; set; } } abstract class DocumentTask { public virtual Document Doc { get;set; } public int B ...
0 votes
1 answer
442 views

I'm building a generic search using expressions, searching in all string properties of the model. However I'm having problems implementing 'Contains' alongside 'ToLower'. Type elementType = typeof(...
2 votes
1 answer
239 views

I'm working on a program that calculates expressions at runtime based on a set of inputs, then executes those remotely. This requires creating expressions dynamically that call different helper ...
2 votes
1 answer
257 views

Consider the following block of code: Expression<Func<string, bool>> pred; { string s = "test"; pred = x => x == s; } // how to retrieve the value of s from just pred? ...
4 votes
2 answers
333 views

Let's say I need to write an expression visitor, which also uses some injectable service, hence it has to have a public constructor, and cannot be simply wrapped in a static facade. public class ...
0 votes
0 answers
108 views

I want to make a method that takes a MemberExpression and does something with it. At the moment I can do private string myfunction<T>(Expression<Func<T>> exp) { if (exp.Body is ...
3 votes
1 answer
1k views

I try to convert an expression in the form Expression<Func<Person,object>> to a string for later manipulation. This expression is stored in a property in a class and it's used in source ...
2 votes
2 answers
2k views

I have a Linq query which is selecting 2 columns(that can be any 2 from all columns) dynamically based on some condition.I need to map the query result in to below model irrespective of selected ...
7 votes
4 answers
4k views

Say I have an Expression<Func<T,object>> is it possible to dynamically change the return type based on a Type variable to be something like Expression<Func<T,int>> I have the ...

1
2 3 4 5
13